20#include <config_features.h>
29#include <com/sun/star/task/InteractionHandler.hpp>
30#include <com/sun/star/task/XStatusIndicator.hpp>
31#include <com/sun/star/uno/Reference.h>
32#include <com/sun/star/ucb/XContent.hpp>
33#include <com/sun/star/container/XChild.hpp>
34#include <com/sun/star/document/XDocumentRevisionListPersistence.hpp>
35#include <com/sun/star/document/LockedDocumentRequest.hpp>
36#include <com/sun/star/document/LockedOnSavingRequest.hpp>
37#include <com/sun/star/document/OwnLockOnDocumentRequest.hpp>
38#include <com/sun/star/document/LockFileIgnoreRequest.hpp>
39#include <com/sun/star/document/LockFileCorruptRequest.hpp>
40#include <com/sun/star/document/ChangedByOthersRequest.hpp>
41#include <com/sun/star/document/ReloadEditableRequest.hpp>
42#include <com/sun/star/embed/XTransactedObject.hpp>
43#include <com/sun/star/embed/ElementModes.hpp>
44#include <com/sun/star/embed/UseBackupException.hpp>
45#include <com/sun/star/embed/XOptimizedStorage.hpp>
46#include <com/sun/star/frame/Desktop.hpp>
47#include <com/sun/star/frame/XModel.hpp>
48#include <com/sun/star/frame/XTerminateListener.hpp>
49#include <com/sun/star/graphic/XGraphic.hpp>
50#include <com/sun/star/ucb/ContentCreationException.hpp>
51#include <com/sun/star/ucb/InteractiveIOException.hpp>
52#include <com/sun/star/ucb/CommandFailedException.hpp>
53#include <com/sun/star/ucb/CommandAbortedException.hpp>
54#include <com/sun/star/ucb/InteractiveLockingLockedException.hpp>
55#include <com/sun/star/ucb/InteractiveNetworkReadException.hpp>
56#include <com/sun/star/ucb/InteractiveNetworkWriteException.hpp>
57#include <com/sun/star/ucb/Lock.hpp>
58#include <com/sun/star/ucb/NameClashException.hpp>
59#include <com/sun/star/ucb/XCommandEnvironment.hpp>
60#include <com/sun/star/ucb/XProgressHandler.hpp>
61#include <com/sun/star/io/XOutputStream.hpp>
62#include <com/sun/star/io/XInputStream.hpp>
63#include <com/sun/star/io/XTruncate.hpp>
64#include <com/sun/star/io/XSeekable.hpp>
65#include <com/sun/star/lang/XSingleServiceFactory.hpp>
66#include <com/sun/star/ucb/InsertCommandArgument.hpp>
67#include <com/sun/star/ucb/NameClash.hpp>
68#include <com/sun/star/beans/NamedValue.hpp>
69#include <com/sun/star/beans/PropertyValue.hpp>
70#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
71#include <com/sun/star/security/XCertificate.hpp>
95#include <osl/file.hxx>
100#include <tools/datetime.hxx>
112#include <com/sun/star/document/DocumentRevisionListPersistence.hpp>
119#include <sfx2/sfxsids.hrc>
122#include <officecfg/Office/Common.hxx>
132#include <condition_variable>
134#include <com/sun/star/io/WrongFormatException.hpp>
149struct ReadOnlyMediumEntry
151 ReadOnlyMediumEntry(std::shared_ptr<std::recursive_mutex> pMutex,
152 std::shared_ptr<bool> pIsDestructed)
153 : _pMutex(
std::move(pMutex))
154 , _pIsDestructed(
std::move(pIsDestructed))
157 std::shared_ptr<std::recursive_mutex> _pMutex;
158 std::shared_ptr<bool> _pIsDestructed;
170#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
172bool IsSystemFileLockingUsed()
174#if HAVE_FEATURE_MACOSX_SANDBOX
177 return officecfg::Office::Common::Misc::UseDocumentSystemFileLocking::get();
182bool IsOOoLockFileUsed()
184#if HAVE_FEATURE_MACOSX_SANDBOX
187 return officecfg::Office::Common::Misc::UseDocumentOOoLockFile::get();
193 return officecfg::Office::Common::Misc::UseLocking::get();
198#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
199bool IsWebDAVLockingUsed()
201 return officecfg::Office::Common::Misc::UseWebDAVFileLocking::get();
206sal_uInt64 GetDefaultFileAttributes(
const OUString& rURL)
214 osl::File aFile(rURL);
215 osl::File::RC nRes = aFile.open(osl_File_OpenFlag_Create);
216 if (nRes != osl::File::E_None && nRes != osl::File::E_EXIST)
221 osl::DirectoryItem aItem;
222 if (osl::DirectoryItem::get(rURL, aItem) != osl::DirectoryItem::E_None)
225 osl::FileStatus aStatus(osl_FileStatus_Mask_Attributes);
226 if (aItem.getFileStatus(aStatus) != osl::DirectoryItem::E_None)
229 nRet = aStatus.getAttributes();
247 OUString sPath = rURL.
getFSysPath(FSysStyle::Unix);
252 if (lstat(sPath.toUtf8().getStr(), &buf) != 0)
256 if (buf.st_nlink > 1 || S_ISLNK(buf.st_mode))
267class CheckReadOnlyTaskTerminateListener
268 :
public ::cppu::WeakImplHelper<css::frame::XTerminateListener>
272 void SAL_CALL disposing(
const css::lang::EventObject&
Source)
override;
275 void SAL_CALL queryTermination(
const css::lang::EventObject&
aEvent)
override;
276 void SAL_CALL notifyTermination(
const css::lang::EventObject&
aEvent)
override;
278 bool bIsTerminated =
false;
279 std::condition_variable mCond;
286 CheckReadOnlyTask(
const std::shared_ptr<comphelper::ThreadTaskTag>& pTag);
287 ~CheckReadOnlyTask();
289 virtual void doWork()
override;
297CheckReadOnlyTask::CheckReadOnlyTask(
const std::shared_ptr<comphelper::ThreadTaskTag>& pTag)
299 ,
m_xListener(new CheckReadOnlyTaskTerminateListener)
301 Reference<css::frame::XDesktop> xDesktop
309CheckReadOnlyTask::~CheckReadOnlyTask()
311 Reference<css::frame::XDesktop> xDesktop
327CheckReadOnlyTaskTerminateListener::disposing(
const css::lang::EventObject& )
332CheckReadOnlyTaskTerminateListener::queryTermination(
const css::lang::EventObject& )
337CheckReadOnlyTaskTerminateListener::notifyTermination(
const css::lang::EventObject& )
339 std::unique_lock<std::mutex>
lock(mMutex);
340 bIsTerminated =
true;
382 mutable std::shared_ptr<SfxItemSet>
m_pSet;
442 bUpdatePickList(true),
444 bDownloadDone( true ),
446 bUseInteractionHandler( true ),
447 bAllowDefaultIntHdl( false ),
448 bDisposeStorage( false ),
449 bStorageBasedOnInStream( false ),
450 m_bSalvageMode( false ),
451 m_bVersionsAlreadyLoaded( false ),
453 m_bMSOLockFileCreated( false ),
454 m_bDisableUnlockWebDAV( false ),
455 m_bGotDateTime( false ),
456 m_bRemoveBackup( false ),
457 m_bOriginallyReadOnly(false),
458 m_bOriginallyLoadedReadOnly(false),
459 m_bTriedStorage(false),
461 m_bInputStreamIsReadOnly(false),
463 m_pReloadEvent(nullptr),
477 std::unique_lock<std::recursive_mutex> chkEditLock;
486 if(
pImpl->m_pInStream )
487 pImpl->m_pInStream->ResetError();
488 if(
pImpl->m_pOutStream )
489 pImpl->m_pOutStream->ResetError();
494 return pImpl->m_eWarningError;
499 return pImpl->nLastStorageError;
504 pImpl->m_eError = nError;
509 pImpl->m_eWarningError = nWarningError;
515 if(!lError &&
pImpl->m_pInStream)
516 lError =
pImpl->m_pInStream->GetErrorCode();
517 if(!lError &&
pImpl->m_pOutStream)
518 lError =
pImpl->m_pOutStream->GetErrorCode();
525 if (
pImpl->m_aDateTime.Seconds == aInitDate.Seconds
526 &&
pImpl->m_aDateTime.Minutes == aInitDate.Minutes
527 &&
pImpl->m_aDateTime.Hours == aInitDate.Hours
528 &&
pImpl->m_aDateTime.Day == aInitDate.Day
529 &&
pImpl->m_aDateTime.Month == aInitDate.Month
530 &&
pImpl->m_aDateTime.Year == aInitDate.Year )
535 if ( !xHandler.is() )
541 document::ChangedByOthersRequest() ) );
542 uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations{
543 new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() ),
544 new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() )
546 xInteractionRequestImpl->setContinuations( aContinuations );
548 xHandler->handle( xInteractionRequestImpl );
551 if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() )
556 catch (
const uno::Exception& )
568 if ( ( bIgnoreOldValue || !
pImpl->m_bGotDateTime ) && !
pImpl->m_aLogicName.isEmpty() )
579 pImpl->m_bGotDateTime =
true;
581 catch (
const css::uno::Exception& )
586 return pImpl->m_aDateTime;
592 if ( !
pImpl->aContent.get().is() )
594 Reference < css::ucb::XContent > xContent;
598 css:: uno::Reference< task::XInteractionHandler > xIH(
601 css::uno::Reference< css::ucb::XProgressHandler > xProgress;
604 const SfxUnoAnyItem* pItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_CONTENT,
false);
622 if ( !
pImpl->m_aName.isEmpty() )
623 osl::FileBase::getFileURLFromSystemPath(
pImpl->m_aName,
aURL );
624 else if ( !
pImpl->m_aLogicName.isEmpty() )
626 if (!
aURL.isEmpty() )
631 return pImpl->aContent.get();
639 if ((bIsRemote && !officecfg::Office::Common::Save::URL::Internet::get())
640 || (!bIsRemote && !officecfg::Office::Common::Save::URL::FileSystem::get()))
645 return pBaseURLItem->GetValue();
652 Any aAny =
pImpl->aContent.getPropertyValue(
"BaseURI");
655 catch (
const css::uno::Exception& )
659 if ( aBaseURL.isEmpty() )
668 return pSkipImagesItem && pSkipImagesItem->
GetValue() ==
"SkipImages";
673 if (
pImpl->m_pInStream )
674 return pImpl->m_pInStream.get();
676 if (
pImpl->pTempFile )
680 pImpl->m_eError =
pImpl->m_pInStream->GetError();
682 if (!
pImpl->m_eError && (
pImpl->m_nStorOpenMode & StreamMode::WRITE)
683 && !
pImpl->m_pInStream->IsWritable() )
686 pImpl->m_pInStream.reset();
689 return pImpl->m_pInStream.get();
697 return pImpl->m_pInStream.get();
711 if (
pImpl->m_pInStream &&
pImpl->xStorage.is() )
713 if (
pImpl->bStorageBasedOnInStream )
723 pImpl->m_pInStream.reset();
725 pImpl->m_pSet->ClearItem( SID_INPUTSTREAM );
728 pImpl->xInputStream.clear();
730 if ( !
pImpl->m_pOutStream )
734 pImpl->xStream.clear();
736 pImpl->m_pSet->ClearItem( SID_STREAM );
743 if ( !
pImpl->m_pOutStream )
749 if (
pImpl->pTempFile )
755 if (getenv(
"SFX_MEDIUM_REUSE_STREAM") &&
pImpl->xStream.is())
757 assert(
pImpl->xStream->getOutputStream().is());
759 pImpl->xStream,
false);
766 pImpl->m_aName, StreamMode::STD_READWRITE) );
772 return pImpl->m_pOutStream.get();
783 if (
pImpl->m_pOutStream )
790 if (
pImpl->xStorage.is() )
795 pImpl->m_pOutStream.reset();
798 if ( !
pImpl->m_pInStream )
802 pImpl->xStream.clear();
804 pImpl->m_pSet->ClearItem( SID_STREAM );
811 if (
pImpl->m_aName.isEmpty() && !
pImpl->m_aLogicName.isEmpty() )
815 return pImpl->m_aName;
822 if(
pImpl->m_pInStream )
830 if(
pImpl->m_pInStream )
833 pImpl->bIsTemp =
true;
841 if(
pImpl->xStorage.is() )
843 else if(
pImpl->m_pOutStream )
844 pImpl->m_pOutStream->FlushBuffer();
845 else if(
pImpl->m_pInStream )
846 pImpl->m_pInStream->FlushBuffer();
867 if (
pImpl->xStorage.is() )
870 if (
pImpl->m_bTriedStorage )
871 return pImpl->bIsStorage;
873 if (
pImpl->pTempFile )
876 if ( osl::FileBase::getFileURLFromSystemPath(
pImpl->m_aName,
aURL )
877 != osl::FileBase::E_None )
879 SAL_WARN(
"sfx.doc",
"Physical name '" <<
pImpl->m_aName <<
"' not convertible to file URL");
882 if ( !
pImpl->bIsStorage )
883 pImpl->m_bTriedStorage =
true;
888 if ( !
pImpl->m_pInStream->GetError() && !
pImpl->bIsStorage )
889 pImpl->m_bTriedStorage =
true;
892 return pImpl->bIsStorage;
898 bool bPreview =
false;
907 OUString aFileFlags = pFlags->
GetValue();
908 aFileFlags = aFileFlags.toAsciiUpperCase();
909 if ( -1 != aFileFlags.indexOf(
'B' ) )
921 Reference< css::ucb::XCommandEnvironment > xDummyEnv;
923 bool bBasedOnOriginalFile =
925 && (
pImpl->m_aLogicName.isEmpty() || !
pImpl->m_bSalvageMode )
930 if ( bBasedOnOriginalFile &&
pImpl->m_aBackupURL.isEmpty()
934 if(
pImpl->m_aBackupURL.isEmpty() )
942 if (
pImpl->m_aBackupURL.isEmpty() )
945 return pImpl->m_aBackupURL;
952 return uno::Reference< embed::XStorage >();
956 if (
pImpl->xStorage.is() && (
pImpl->m_aLogicName.isEmpty() ||
pImpl->pTempFile ) )
957 return pImpl->xStorage;
960 if (
pImpl->m_pInStream && !
pImpl->m_pInStream->IsWritable() )
963 DBG_ASSERT( !
pImpl->m_pOutStream,
"OutStream in a readonly Medium?!" );
977 if ( !
pImpl->xStorage.is() || !
pImpl->m_pSet )
980 uno::Sequence< beans::NamedValue > aEncryptionData;
985 pImpl->m_pSet->ClearItem( SID_PASSWORD );
992 catch(
const uno::Exception& )
994 SAL_WARN(
"sfx.doc",
"It must be possible to set a common password for the storage" );
1000#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
1020OUString tryMSOwnerFiles(std::u16string_view sDocURL)
1026 aData = aMSOLockFile.GetLockData();
1028 catch(
const uno::Exception& )
1033 OUString sUserData =
aData[LockFileComponent::OOOUSERNAME];
1035 if (!sUserData.isEmpty())
1036 sUserData +=
" (MS Office)";
1041OUString tryForeignLockfiles(std::u16string_view sDocURL)
1043 OUString sUserData = tryMSOwnerFiles(sDocURL);
1045 return sUserData.trim();
1050 bool bIsLoading,
bool bOwnLock,
1051 bool bHandleSysLocked)
1056 if(
aData[LockFileComponent::OOOUSERNAME].isEmpty() &&
aData[LockFileComponent::SYSUSERNAME].isEmpty() && !bHandleSysLocked )
1062 if ( xHandler.is() && ( bIsLoading || !bHandleSysLocked || bOwnLock ) )
1064 OUString aDocumentURL
1069 sal_Int32 nContinuations = 3;
1073 aInfo =
aData[LockFileComponent::EDITTIME];
1075 xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
uno::Any(
1076 document::OwnLockOnDocumentRequest( OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo, !bIsLoading ) ) );
1082 if (!bHandleSysLocked)
1085 if ( !
aData[LockFileComponent::OOOUSERNAME].isEmpty() )
1086 aInfo =
aData[LockFileComponent::OOOUSERNAME];
1088 aInfo =
aData[LockFileComponent::SYSUSERNAME];
1090 if (aInfo.isEmpty() && !
GetURLObject().isAnyKnownWebDAVScheme())
1092 aInfo = tryForeignLockfiles(
1095 if ( !aInfo.isEmpty() && !
aData[LockFileComponent::EDITTIME].isEmpty() )
1096 aInfo +=
" ( " +
aData[LockFileComponent::EDITTIME] +
" )";
1100 xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
uno::Any(
1101 document::LockedOnSavingRequest(OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo)));
1106 xInteractionRequestImpl = new ::ucbhelper::InteractionRequest(
uno::Any(
1107 document::LockedDocumentRequest( OUString(), uno::Reference< uno::XInterface >(), aDocumentURL, aInfo ) ) );
1111 uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations(nContinuations);
1112 auto pContinuations = aContinuations.getArray();
1113 pContinuations[0] = new ::ucbhelper::InteractionAbort( xInteractionRequestImpl.get() );
1114 pContinuations[1] = new ::ucbhelper::InteractionApprove( xInteractionRequestImpl.get() );
1115 pContinuations[2] = new ::ucbhelper::InteractionDisapprove( xInteractionRequestImpl.get() );
1116 if (nContinuations > 3)
1120 pContinuations[3] = new ::ucbhelper::InteractionRetry(xInteractionRequestImpl.get());
1122 xInteractionRequestImpl->setContinuations( aContinuations );
1124 xHandler->handle( xInteractionRequestImpl );
1126 bool bOpenReadOnly =
false;
1128 if ( uno::Reference< task::XInteractionAbort >( xSelected.get(), uno::UNO_QUERY ).is() )
1132 else if ( uno::Reference< task::XInteractionDisapprove >( xSelected.get(), uno::UNO_QUERY ).is() )
1146 else if (uno::Reference< task::XInteractionRetry >(xSelected.get(), uno::UNO_QUERY).is())
1151 else if (uno::Reference< task::XInteractionApprove >( xSelected.get(), uno::UNO_QUERY ).is())
1153 bOpenReadOnly =
true;
1157 pImpl->m_bNotifyWhenEditable =
true;
1159 bOpenReadOnly =
true;
1204 xIgnoreRequestImpl = new ::ucbhelper::InteractionRequest(
uno::Any( document::LockFileIgnoreRequest() ));
1207 xIgnoreRequestImpl = new ::ucbhelper::InteractionRequest(
uno::Any( document::LockFileCorruptRequest() ));
1211 uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations{
1212 new ::ucbhelper::InteractionAbort(xIgnoreRequestImpl.get()),
1213 new ::ucbhelper::InteractionApprove(xIgnoreRequestImpl.get())
1215 xIgnoreRequestImpl->setContinuations(aContinuations);
1217 xHandler->handle(xIgnoreRequestImpl);
1222 if (uno::Reference<task::XInteractionAbort>(xSelected.get(), uno::UNO_QUERY).is())
1227 else if (!uno::Reference<task::XInteractionApprove>(xSelected.get(), uno::UNO_QUERY).is())
1230 pImpl->m_bNotifyWhenEditable =
true;
1245 bool isSuitableProtocolForLocking(
const OUString & rLogicName)
1249#if !HAVE_FEATURE_MACOSX_SANDBOX
1250 if (eProt == INetProtocol::File) {
1254 return eProt == INetProtocol::Smb || eProt == INetProtocol::Sftp;
1263class LockInteractionHandler :
public ::cppu::WeakImplHelper<task::XInteractionHandler>
1266 uno::Reference<task::XInteractionHandler>
m_xHandler;
1269 explicit LockInteractionHandler(uno::Reference<task::XInteractionHandler>
const& xHandler)
1274 virtual void SAL_CALL handle(uno::Reference<task::XInteractionRequest>
const& xRequest)
override
1276 ucb::InteractiveNetworkWriteException readException;
1277 ucb::InteractiveNetworkReadException writeException;
1278 if ((xRequest->getRequest() >>= readException)
1279 || (xRequest->getRequest() >>= writeException))
1294 bool bTryIgnoreLockFile,
1297#if !HAVE_FEATURE_MULTIUSER_ENVIRONMENT
1300 (void) bTryIgnoreLockFile;
1313 if (!IsWebDAVLockingUsed())
1317 bool bResult =
pImpl->m_bLocked;
1318 bool bIsTemplate =
false;
1324 bIsTemplate = ( bLoading && pTemplateItem && pTemplateItem->
GetValue() );
1327 if ( !bIsTemplate && !bResult && !
IsReadOnly() )
1338 if (bLoading || bNoUI)
1340 xCHandler =
new LockInteractionHandler(xCHandler);
1342 Reference< css::ucb::XCommandEnvironment > xComEnv = new ::ucbhelper::CommandEnvironment(
1343 xCHandler, Reference< css::ucb::XProgressHandler >() );
1351 aContentToLock.
lock();
1354 catch ( ucb::InteractiveLockingLockedException& )
1357 if (!bNoUI || pLockData)
1364 aLockData[LockFileComponent::OOOUSERNAME] =
"Unknown user";
1371 aLockData[LockFileComponent::SYSUSERNAME]
1372 = aOwnData[LockFileComponent::SYSUSERNAME];
1374 uno::Sequence<css::ucb::Lock> aLocks;
1376 if ((aContentToLock.
getPropertyValue(
"DAV:lockdiscovery") >>= aLocks) && aLocks.hasElements())
1379 css::ucb::Lock aLock = aLocks[0];
1381 if (aLock.Owner >>= aOwner)
1384 aLockData[LockFileComponent::OOOUSERNAME] = aOwner;
1396 std::copy(aLockData.
begin(), aLockData.
end(), pLockData->
begin());
1400 catch( ucb::InteractiveNetworkWriteException& )
1413 catch( uno::Exception& )
1421 pImpl->m_bLocked = bResult;
1427 const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(
pImpl->m_pSet.get(), SID_DOC_READONLY,
false);
1429 if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->
GetValue()) )
1445 if (!IsLockingUsed())
1452 if (
pImpl->m_bLocked && bLoading
1453 &&
GetURLObject().GetProtocol() == INetProtocol::File )
1460 bool bResult =
pImpl->m_bLocked;
1466 bResult = ( bLoading && pTemplateItem && pTemplateItem->
GetValue() );
1471 bool bContentReadonly =
false;
1482 if ( bLoading && !
pImpl->m_xLockingStream.is() )
1487 Reference< css::ucb::XCommandEnvironment > xDummyEnv;
1491 catch(
const uno::Exception& ) {}
1495 if ( !bContentReadonly )
1498 if ( isSuitableProtocolForLocking(
pImpl->m_aLogicName ) )
1518 bool bHandleSysLocked = ( bLoading && bUseSystemLock && !
pImpl->xStream.is() && !
pImpl->m_pOutStream );
1521 std::unique_ptr<osl::File> pFileLock;
1522 if (!bLoading && bUseSystemLock &&
pImpl->pTempFile)
1529 pFileLock = std::make_unique<osl::File>(aDestURL);
1530 auto rc = pFileLock->open(osl_File_OpenFlag_Write);
1531 if (rc == osl::FileBase::E_ACCES)
1532 bHandleSysLocked =
true;
1542 std::unique_ptr<svt::MSODocumentLockFile> pMSOLockFile;
1547 pImpl->m_bMSOLockFileCreated =
true;
1550 bool bIoErr =
false;
1552 if (!bHandleSysLocked)
1558 bResult &= pMSOLockFile->CreateOwnLockFile();
1560 catch (
const uno::Exception&)
1569 else if (bLoading && !bNoUI)
1579 if (!bResult && !IsOOoLockFileUsed() && !bIoErr)
1586 pMSOLockFile->OverwriteOwnLockFile();
1597 catch (
const io::WrongFormatException&)
1601 if (!bIoErr && bLoading && !bNoUI )
1607 catch(
const uno::Exception& )
1610 bIoErr = !bHandleSysLocked;
1613 bool bOwnLock =
false;
1615 if (!bHandleSysLocked)
1618 bOwnLock = aOwnData[LockFileComponent::SYSUSERNAME] ==
aData[LockFileComponent::SYSUSERNAME];
1621 && aOwnData[LockFileComponent::LOCALHOST] ==
aData[LockFileComponent::LOCALHOST]
1622 && aOwnData[LockFileComponent::USERURL] ==
aData[LockFileComponent::USERURL])
1629 if ( !bResult && !bIoErr)
1633 aData, bLoading, bOwnLock, bHandleSysLocked);
1634 else if (bLoading && bTryIgnoreLockFile && !bHandleSysLocked)
1643 pMSOLockFile->OverwriteOwnLockFile();
1645 else if (bLoading && !bHandleSysLocked)
1648 if (!bResult && pLockData)
1655 catch(
const uno::Exception& )
1660 pImpl->m_bLocked = bResult;
1665 bResult = !bContentReadonly;
1678 const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(
pImpl->m_pSet.get(), SID_DOC_READONLY,
false);
1680 if ( !bLoading || (pReadOnlyItem && !pReadOnlyItem->
GetValue()) )
1693 catch(
const uno::Exception& )
1695 TOOLS_WARN_EXCEPTION(
"sfx.doc",
"Locking exception: high probability, that the content has not been created" );
1705 if (
pImpl->xStorage.is() ||
pImpl->m_bTriedStorage )
1706 return pImpl->xStorage;
1708 uno::Sequence< uno::Any > aArgs( 2 );
1709 auto pArgs = aArgs.getArray();
1715 if ( bCreateTempFile )
1721 return pImpl->xStorage;
1724 if ( pRepairItem && pRepairItem->
GetValue() )
1730 Reference< css::ucb::XProgressHandler > xProgressHandler;
1731 Reference< css::task::XStatusIndicator > xStatusIndicator;
1734 if( pxProgressItem && ( pxProgressItem->
GetValue() >>= xStatusIndicator ) )
1735 xProgressHandler.set(
new utl::ProgressHandlerWrap( xStatusIndicator ) );
1737 uno::Sequence< beans::PropertyValue > aAddProps{
1744 pArgs = aArgs.getArray();
1745 pArgs[2] <<= aAddProps;
1748 if (
pImpl->xStream.is() )
1751 pArgs[0] <<=
pImpl->xStream;
1752 pArgs[1] <<= embed::ElementModes::READWRITE;
1753 pImpl->bStorageBasedOnInStream =
true;
1754 if (
pImpl->m_bDisableFileSync)
1758 pArgs = aArgs.getArray();
1764 else if (
pImpl->xInputStream.is() )
1767 pArgs[0] <<=
pImpl->xInputStream;
1768 pArgs[1] <<= embed::ElementModes::READ;
1769 pImpl->bStorageBasedOnInStream =
true;
1774 pArgs[0] <<=
pImpl->m_aName;
1775 pArgs[1] <<= embed::ElementModes::READ;
1776 pImpl->bStorageBasedOnInStream =
false;
1784 catch(
const uno::Exception& )
1791 pImpl->xStorage =
nullptr;
1792 if (
pImpl->m_pInStream )
1793 pImpl->m_pInStream->Seek(0);
1794 return uno::Reference< embed::XStorage >();
1797 pImpl->m_bTriedStorage =
true;
1800 if (
pImpl->xStorage.is() )
1806 const SfxInt16Item* pVersion = SfxItemSet::GetItem<SfxInt16Item>(
pImpl->m_pSet.get(), SID_VERSION,
false);
1808 bool bResetStorage =
false;
1809 if ( pVersion && pVersion->
GetValue() )
1812 if (
pImpl->aVersions.hasElements() )
1827 uno::Reference < embed::XStorage > xSub =
pImpl->xStorage->openStorageElement(
"Versions",
1828 embed::ElementModes::READ );
1830 DBG_ASSERT( xSub.is(),
"Version list, but no Versions!" );
1833 uno::Reference < io::XStream > xStr = xSub->openStreamElement( rTag.Identifier, embed::ElementModes::READ );
1838 const OUString aTmpName = ::utl::CreateTempURL();
1841 pStream->ReadStream( aTmpStream );
1848 pImpl->bStorageBasedOnInStream =
false;
1850 osl::FileBase::getSystemPathFromFileURL( aTmpName, aTemp );
1853 pImpl->bIsTemp =
true;
1856 pImpl->aVersions.realloc(0);
1859 bResetStorage =
true;
1863 bResetStorage =
true;
1866 if ( bResetStorage )
1868 pImpl->xStorage.clear();
1869 if (
pImpl->m_pInStream )
1870 pImpl->m_pInStream->Seek( 0 );
1874 return pImpl->xStorage;
1892 else if (
pImpl->xInputStream.is() )
1897 catch(
const uno::Exception& )
1899 SAL_WARN(
"sfx.doc",
"No possibility to get readonly version of storage from medium!" );
1906 return pImpl->m_xZipStorage;
1912 if (
pImpl->m_xZipStorage.is() )
1915 pImpl->m_xZipStorage->dispose();
1916 }
catch(
const uno::Exception& )
1919 pImpl->m_xZipStorage.clear();
1925 if (
pImpl->xStorage.is() )
1927 uno::Reference < lang::XComponent > xComp =
pImpl->xStorage;
1929 if (
pImpl->bDisposeStorage && !
pImpl->m_bSalvageMode )
1933 }
catch(
const uno::Exception& )
1935 SAL_WARN(
"sfx.doc",
"Medium's storage is already disposed!" );
1939 pImpl->xStorage.clear();
1940 pImpl->bStorageBasedOnInStream =
false;
1943 pImpl->m_bTriedStorage =
false;
1944 pImpl->bIsStorage =
false;
1949 pImpl->bDisposeStorage = bDisposeStorage;
1954 return pImpl->bDisposeStorage;
1959 return pImpl->m_nStorOpenMode;
1965 if (
pImpl->m_nStorOpenMode != nStorOpen )
1967 pImpl->m_nStorOpenMode = nStorOpen;
1971 if (
pImpl->xStorage.is() )
1981 const Reference< css::ucb::XCommandEnvironment >& xComEnv )
1987 Reference< XInputStream > aOrigInput = aTransactCont.
openStream();
1995 pImpl->m_bRemoveBackup =
false;
2006 bool bResult =
false;
2007 Reference< css::ucb::XCommandEnvironment > xDummyEnv;
2010 if (
pImpl->xStorage.is() )
2014 uno::Reference < embed::XTransactedObject > xTrans(
pImpl->xStorage, uno::UNO_QUERY );
2023 catch (
const embed::UseBackupException& aBackupExc )
2026 if ( !
pImpl->pTempFile )
2028 OSL_ENSURE( !
pImpl->m_aBackupURL.isEmpty(),
"No backup on storage commit!" );
2029 if ( !
pImpl->m_aBackupURL.isEmpty()
2032 aOriginalContent ) )
2041 pImpl->m_aName = aBackupExc.TemporaryFileURL;
2042 OSL_ENSURE( !
pImpl->m_aName.isEmpty(),
"The exception _must_ contain the temporary URL!" );
2050 catch (
const uno::Exception& )
2065 const Reference< css::ucb::XCommandEnvironment >& xComEnv )
2067 Reference< css::ucb::XCommandEnvironment > xDummyEnv;
2074 catch (
const css::ucb::CommandAbortedException& )
2078 catch (
const css::ucb::CommandFailedException& )
2082 catch (
const css::ucb::ContentCreationException&
ex)
2086 (
ex.eError == css::ucb::ContentCreationError_NO_CONTENT_PROVIDER ) ||
2087 (
ex.eError == css::ucb::ContentCreationError_CONTENT_CREATION_FAILED)
2093 catch (
const css::uno::Exception&)
2098 if(
pImpl->m_eError && !
pImpl->m_eError.IsWarning() )
2101 if (
pImpl->xStorage.is() )
2109 bool bTransactStarted =
false;
2111 bool bOverWrite = !pOverWrite || pOverWrite->
GetValue();
2112 bool bResult =
false;
2119 && ::utl::UCBContentHelper::IsDocument(
2122 Reference< XInputStream > aTempInput = aTempCont.
openStream();
2123 aOriginalContent.
writeStream( aTempInput, bOverWrite );
2129 sal_uInt64
nAttributes = GetDefaultFileAttributes(aDestMainURL);
2130 if (IsFileMovable(aDest)
2131 && osl::File::replace(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None)
2136 osl::File::setAttributes(aDestMainURL,
nAttributes);
2141 if(
pImpl->m_aBackupURL.isEmpty() )
2144 if( !
pImpl->m_aBackupURL.isEmpty() )
2146 Reference< XInputStream > aTempInput = aTempCont.
openStream();
2147 bTransactStarted =
true;
2149 aOriginalContent.
writeStream( aTempInput, bOverWrite );
2159 catch (
const css::ucb::CommandAbortedException& )
2163 catch (
const css::ucb::CommandFailedException& )
2167 catch (
const css::ucb::InteractiveIOException& r )
2169 if ( r.Code == IOErrorCode_ACCESS_DENIED )
2171 else if ( r.Code == IOErrorCode_NOT_EXISTING )
2173 else if ( r.Code == IOErrorCode_CANT_READ )
2179 catch (
const css::ucb::NameClashException& )
2183 catch (
const css::uno::Exception& )
2190 if (
pImpl->pTempFile )
2192 pImpl->pTempFile->EnableKillingFile();
2193 pImpl->pTempFile.reset();
2216 if ( ( !pNewPassItem && !pOldPassItem )
2217 || ( pNewPassItem && pOldPassItem && pNewPassItem->
GetValue() == pOldPassItem->
GetValue() ) )
2222 if ( pNewFilterItem && pOldFilterItem && pNewFilterItem->
GetValue() == pOldFilterItem->
GetValue() )
2229 if ( xInStream.is() )
2233 uno::Reference< io::XSeekable > xSeek( xInStream, uno::UNO_QUERY );
2237 nPos = xSeek->getPosition();
2241 uno::Reference < css::ucb::XCommandEnvironment > xEnv;
2244 InsertCommandArgument aInsertArg;
2245 aInsertArg.Data = xInStream;
2247 if ( pOverWrite && !pOverWrite->
GetValue() )
2248 aInsertArg.ReplaceExisting =
false;
2250 aInsertArg.ReplaceExisting =
true;
2253 aCmdArg <<= aInsertArg;
2258 xSeek->seek(
nPos );
2262 catch(
const uno::Exception& )
2276 if (
pImpl->pTempFile )
2277 aNameURL =
pImpl->pTempFile->GetURL();
2278 else if ( !
pImpl->m_aLogicName.isEmpty() &&
pImpl->m_bSalvageMode )
2281 if ( osl::FileBase::getFileURLFromSystemPath(
pImpl->m_aName, aNameURL )
2282 != osl::FileBase::E_None )
2283 SAL_WARN(
"sfx.doc",
"The medium name is not convertible!" );
2286 if ( aNameURL.isEmpty() || (
pImpl->m_eError && !
pImpl->m_eError.IsWarning() ) )
2289 SAL_INFO(
"sfx.doc",
"SfxMedium::Transfer_Impl, copying to target" );
2291 Reference < css::ucb::XCommandEnvironment > xEnv;
2292 Reference< XOutputStream > rOutStream;
2296 if (
pImpl->m_aLogicName.startsWith(
"private:stream"))
2299 const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_OUTPUTSTREAM,
false);
2300 if( pOutStreamItem && ( pOutStreamItem->
GetValue() >>= rOutStream ) )
2302 if (
pImpl->xStorage.is() )
2314 sal_Int32 nBufferSize = 32767;
2315 Sequence < sal_Int8 > aSequence ( nBufferSize );
2316 Reference< XInputStream > aTempInput = aTempCont.
openStream();
2320 nRead = aTempInput->readBytes ( aSequence, nBufferSize );
2321 if ( nRead < nBufferSize )
2323 Sequence < sal_Int8 > aTempBuf ( aSequence.getConstArray(), nRead );
2324 rOutStream->writeBytes ( aTempBuf );
2327 rOutStream->writeBytes ( aSequence );
2329 while ( nRead == nBufferSize );
2332 if (
pImpl->pTempFile )
2334 pImpl->pTempFile->EnableKillingFile();
2335 pImpl->pTempFile.reset();
2344 SAL_WARN(
"sfx.doc",
"Illegal Output stream parameter!" );
2349 if (
pImpl->m_pSet )
2350 pImpl->m_pSet->ClearItem( SID_OUTPUTSTREAM );
2356 if ( !
pImpl->aContent.get().is() )
2369 Reference< css::ucb::XCommandEnvironment > xComEnv;
2371 Reference< css::task::XInteractionHandler > xInteractionHandler =
GetInteractionHandler(bForceInteractionHandler);
2372 if (xInteractionHandler.is())
2373 xComEnv = new ::ucbhelper::CommandEnvironment( xInteractionHandler,
2374 Reference< css::ucb::XProgressHandler >() );
2382 if (!
pImpl->m_bDisableFileSync)
2385 osl::File aFile( aDestURL );
2386 if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None )
2389 SAL_INFO(
"sfx.doc",
"fsync'd saved file '" << aDestURL <<
"'" );
2408 Reference< css::container::XChild> xChild( aDestContent.
get(), uno::UNO_QUERY );
2409 OUString sParentUrl;
2412 Reference< css::ucb::XContent > xParent( xChild->getParent( ), uno::UNO_QUERY );
2413 if ( xParent.is( ) )
2415 sParentUrl = xParent->getIdentifier( )->getContentIdentifier();
2419 if ( sParentUrl.isEmpty() )
2423 aDestURL = sParentUrl;
2437 catch (uno::Exception
const&)
2439 SAL_INFO(
"sfx.doc",
"exception while getting Title or ObjectId");
2441 if ( aFileName.isEmpty() )
2448 catch (
const css::ucb::ContentCreationException&
ex)
2452 (
ex.eError == css::ucb::ContentCreationError_NO_CONTENT_PROVIDER ) ||
2453 (
ex.eError == css::ucb::ContentCreationError_CONTENT_CREATION_FAILED)
2459 catch (
const css::uno::Exception&)
2464 if ( !
pImpl->m_eError ||
pImpl->m_eError.IsWarning() )
2467 if (
pImpl->xStorage.is() )
2476 sal_Int32 nNameClash;
2477 if ( pOverWrite && !pOverWrite->
GetValue() )
2479 nNameClash = NameClash::ERROR;
2482 nNameClash = NameClash::OVERWRITE;
2488 bool bMajor =
false;
2492 eOperation = ::ucbhelper::InsertOperation::Checkin;
2494 bMajor = pMajor && pMajor->
GetValue( );
2499 OUString sResultURL;
2501 aSourceContent, eOperation,
2502 aFileName, nNameClash,
aMimeType, bMajor, sComment,
2503 &sResultURL, sObjectId );
2505 if ( !sResultURL.isEmpty( ) )
2521 aLockContent.
lock();
2524 catch ( css::uno::Exception & )
2529 catch (
const css::ucb::CommandAbortedException& )
2533 catch (
const css::ucb::CommandFailedException& )
2537 catch (
const css::ucb::InteractiveIOException& r )
2539 if ( r.Code == IOErrorCode_ACCESS_DENIED )
2541 else if ( r.Code == IOErrorCode_NOT_EXISTING )
2543 else if ( r.Code == IOErrorCode_CANT_READ )
2548 catch (
const css::uno::Exception& )
2557 if ( ( !
pImpl->m_eError ||
pImpl->m_eError.IsWarning() ) && !
pImpl->pTempFile )
2560 if (osl::FileBase::getSystemPathFromFileURL(
2562 != osl::FileBase::E_None)
2564 pImpl->m_aName.clear();
2566 pImpl->m_bSalvageMode =
false;
2572 std::u16string_view aPrefix,
2573 std::u16string_view aExtension,
2574 const OUString& aDestDir )
2576 if ( !
pImpl->m_aBackupURL.isEmpty() )
2584 Reference < css::ucb::XCommandEnvironment > xDummyEnv;
2590 OUString sMimeType =
pImpl->getFilterMimeType();
2594 NameClash::OVERWRITE,
2597 pImpl->m_bRemoveBackup =
true;
2603 if (
pImpl->m_aBackupURL.isEmpty() )
2610 if ( !
pImpl->m_aBackupURL.isEmpty() )
2617 sal_Int32 nPrefixLen = aFileName.lastIndexOf(
'.' );
2618 OUString aPrefix = ( nPrefixLen == -1 ) ? aFileName : aFileName.copy( 0, nPrefixLen );
2619 OUString aExtension = ( nPrefixLen == -1 ) ? OUString() : aFileName.copy( nPrefixLen );
2624 Reference < css::ucb::XCommandEnvironment > xEnv;
2628 if ( !
pImpl->m_aBackupURL.isEmpty() )
2653 bool bSuccess =
false;
2654 bool bOnErrorRetryUsingBackupPath =
false;
2658 if (!bForceUsingBackupPath
2659 && officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get())
2662 bOnErrorRetryUsingBackupPath =
true;
2666 if( !aBakDir.isEmpty() )
2670 Reference < css::ucb::XCommandEnvironment > xEnv;
2688 OUString sMimeType =
pImpl->getFilterMimeType();
2692 NameClash::OVERWRITE,
2695 pImpl->m_bRemoveBackup =
false;
2698 catch (
const css::uno::Exception& )
2708 if (bOnErrorRetryUsingBackupPath)
2718 if(
pImpl->m_bRemoveBackup )
2722 if ( !
pImpl->m_aBackupURL.isEmpty() )
2724 if ( ::utl::UCBContentHelper::Kill(
pImpl->m_aBackupURL ) )
2726 pImpl->m_bRemoveBackup =
false;
2727 pImpl->m_aBackupURL.clear();
2732 SAL_WARN(
"sfx.doc",
"Couldn't remove backup file!");
2737 pImpl->m_aBackupURL.clear();
2743 if (
GetURLObject().GetProtocol() != INetProtocol::File
2744 ||
pImpl->m_xLockingStream.is() )
2747 const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_STREAM,
false);
2748 if ( pWriteStreamItem )
2751 if (
pImpl->m_xLockingStream.is() )
2755 uno::Sequence< beans::PropertyValue > xProps;
2761 uno::Reference< io::XInputStream > xInputStream;
2765 if ( !
pImpl->pTempFile &&
pImpl->m_aName.isEmpty() )
2768 if (
pImpl->m_xLockingStream.is() )
2771 if ( xInputStream.is() )
2772 pImpl->xInputStream = xInputStream;
2774 if ( !
pImpl->xInputStream.is() &&
pImpl->xStream.is() )
2775 pImpl->xInputStream =
pImpl->xStream->getInputStream();
2782 if (
pImpl->m_pInStream
2783 && (!
pImpl->bIsTemp ||
pImpl->xInputStream.is() ||
pImpl->m_xInputStreamToLoadFrom.is() ||
pImpl->xStream.is() ||
pImpl->m_xLockingStream.is() ) )
2786 pImpl->bDownloadDone =
false;
2790 const SfxUnoAnyItem* pWriteStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_STREAM,
false);
2791 const SfxUnoAnyItem* pInStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_INPUTSTREAM,
false);
2792 if ( pWriteStreamItem )
2796 if ( pInStreamItem )
2799 if ( !
pImpl->xInputStream.is() &&
pImpl->xStream.is() )
2800 pImpl->xInputStream =
pImpl->xStream->getInputStream();
2802 else if ( pInStreamItem )
2808 uno::Sequence < beans::PropertyValue > xProps;
2810 if (!
pImpl->m_aName.isEmpty())
2812 if ( osl::FileBase::getFileURLFromSystemPath(
pImpl->m_aName, aFileName )
2813 != osl::FileBase::E_None )
2815 SAL_WARN(
"sfx.doc",
"Physical name not convertible!");
2823 bool bFromTempFile = (
pImpl->pTempFile != nullptr );
2825 if ( !bFromTempFile )
2828 if( !(
pImpl->m_nStorOpenMode & StreamMode::WRITE) )
2830 if (xInteractionHandler.is())
2834 if (
pImpl->m_xInputStreamToLoadFrom.is() )
2836 pImpl->xInputStream =
pImpl->m_xInputStreamToLoadFrom;
2837 if (
pImpl->m_bInputStreamIsReadOnly)
2845 if (
pImpl->m_xLockingStream.is() && !bFromTempFile )
2852 if ( bFromTempFile )
2858 else if (
GetURLObject().GetProtocol() == INetProtocol::File )
2882 if ( !
pImpl->xInputStream.is() &&
pImpl->xStream.is() )
2883 pImpl->xInputStream =
pImpl->xStream->getInputStream();
2886 if ( !bFromTempFile )
2889 if (
pImpl->xStream.is() )
2902 if (
pImpl->xStream.is() )
2904 else if (
pImpl->xInputStream.is() )
2908 pImpl->bDownloadDone =
true;
2909 pImpl->aDoneLink.ClearPendingCall();
2911 pImpl->aDoneLink.Call(
reinterpret_cast<void*
>(sal_uInt32(nError)) );
2916 return pImpl->m_bRemote;
2921 pImpl->bUpdatePickList = bVal;
2926 return pImpl->bUpdatePickList;
2931 pImpl->m_aLongName = rName;
2936 return pImpl->m_aLongName;
2941 pImpl->aDoneLink = rLink;
2964 Reference< XOutputStream > rOutStream;
2967 pImpl->bDisposeStorage =
false;
2969 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(
pImpl->m_pSet.get(), SID_DOC_SALVAGE,
false);
2970 if ( pSalvageItem && pSalvageItem->
GetValue().isEmpty() )
2972 pSalvageItem =
nullptr;
2973 pImpl->m_pSet->ClearItem( SID_DOC_SALVAGE );
2976 if (!
pImpl->m_aLogicName.isEmpty())
2980 if ( eProt == INetProtocol::NotValid )
2982 SAL_WARN(
"sfx.doc",
"URL <" <<
pImpl->m_aLogicName <<
"> with unknown protocol" );
2988 std::unique_lock<std::recursive_mutex> chkEditLock;
2989 if (
pImpl->m_pCheckEditableWorkerMutex !=
nullptr)
2990 chkEditLock = std::unique_lock<std::recursive_mutex>(
2991 *(
pImpl->m_pCheckEditableWorkerMutex));
2993 if (chkEditLock.owns_lock())
2994 chkEditLock.unlock();
3000 if (
pImpl->m_aName.isEmpty() )
3004 DBG_ASSERT( pSalvageItem,
"Suspicious change of logical name!" );
3011 std::unique_lock<std::recursive_mutex> chkEditLock;
3012 if (
pImpl->m_pCheckEditableWorkerMutex !=
nullptr)
3014 = std::unique_lock<std::recursive_mutex>(*(
pImpl->m_pCheckEditableWorkerMutex));
3016 pImpl->m_pURLObj.reset();
3017 if (chkEditLock.owns_lock())
3018 chkEditLock.unlock();
3019 pImpl->m_bSalvageMode =
true;
3024 const SfxUnoAnyItem* pOutStreamItem = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_OUTPUTSTREAM,
false);
3026 && ( !( pOutStreamItem->
GetValue() >>= rOutStream )
3027 || !
pImpl->m_aLogicName.startsWith(
"private:stream")) )
3029 pImpl->m_pSet->ClearItem( SID_OUTPUTSTREAM );
3030 SAL_WARN(
"sfx.doc",
"Unexpected Output stream parameter!" );
3033 if (!
pImpl->m_aLogicName.isEmpty())
3036 const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(
pImpl->m_pSet.get(), SID_FILE_NAME,
false);
3037 if ( !pFileNameItem )
3048 osl::DirectoryItem item;
3049 if (osl::DirectoryItem::get(
GetName(), item) == osl::FileBase::E_None) {
3050 osl::FileStatus stat(osl_FileStatus_Mask_Attributes);
3051 if (item.getFileStatus(stat) == osl::FileBase::E_None
3052 && stat.isValid(osl_FileStatus_Mask_Attributes))
3054 if ((stat.getAttributes() & osl_File_Attribute_ReadOnly) != 0)
3056 pImpl->m_bOriginallyReadOnly =
true;
3071 pImpl->bAllowDefaultIntHdl = bUse;
3075css::uno::Reference< css::task::XInteractionHandler >
3079 if ( !bGetAlways && !
pImpl->bUseInteractionHandler )
3080 return css::uno::Reference< css::task::XInteractionHandler >();
3083 if (
pImpl->m_pSet )
3085 css::uno::Reference< css::task::XInteractionHandler > xHandler;
3086 const SfxUnoAnyItem* pHandler = SfxItemSet::GetItem<SfxUnoAnyItem>(
pImpl->m_pSet.get(), SID_INTERACTIONHANDLER,
false);
3087 if ( pHandler && (pHandler->
GetValue() >>= xHandler) && xHandler.is() )
3092 if ( !bGetAlways && !
pImpl->bAllowDefaultIntHdl )
3093 return css::uno::Reference< css::task::XInteractionHandler >();
3096 if (
pImpl->xInteraction.is() )
3097 return pImpl->xInteraction;
3100 Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
3101 pImpl->xInteraction.set(
3102 task::InteractionHandler::createWithParent(xContext,
nullptr), UNO_QUERY_THROW );
3103 return pImpl->xInteraction;
3108 pImpl->m_pFilter = pFilter;
3113 return pImpl->m_pFilter;
3118 sal_uInt32 nHash = 0;
3120 if ( !aPasswd.empty() )
3128 rtl_TextEncoding nEncoding = osl_getThreadTextEncoding();
3139 if (
pImpl->xStorage.is() )
3151 if (
pImpl->xStorage.is() )
3163 pImpl->m_bDisableUnlockWebDAV = bDisableUnlockWebDAV;
3168 pImpl->m_bDisableFileSync = bDisableFileSync;
3173#if !HAVE_FEATURE_MULTIUSER_ENVIRONMENT
3174 (void) bReleaseLockStream;
3182 if (!IsWebDAVLockingUsed())
3185 if (
pImpl->m_bLocked )
3190 uno::Reference< css::ucb::XCommandEnvironment > xComEnv = new ::ucbhelper::CommandEnvironment( xHandler,
3191 Reference< css::ucb::XProgressHandler >() );
3193 pImpl->m_bLocked =
false;
3195 if ( !
pImpl->m_bDisableUnlockWebDAV )
3196 aContentToUnlock.
unlock();
3198 catch ( uno::Exception& )
3206 if (
pImpl->m_xLockingStream.is() )
3208 if ( bReleaseLockStream )
3212 uno::Reference< io::XInputStream > xInStream =
pImpl->m_xLockingStream->getInputStream();
3213 uno::Reference< io::XOutputStream > xOutStream =
pImpl->m_xLockingStream->getOutputStream();
3214 if ( xInStream.is() )
3215 xInStream->closeInput();
3216 if ( xOutStream.is() )
3217 xOutStream->closeOutput();
3219 catch(
const uno::Exception& )
3223 pImpl->m_xLockingStream.clear();
3226 if ( !
pImpl->m_bLocked )
3233 pImpl->m_bLocked =
false;
3237 catch(
const io::WrongFormatException& )
3244 catch(
const uno::Exception& )
3247 catch(
const uno::Exception& )
3250 if(!
pImpl->m_bMSOLockFileCreated)
3257 pImpl->m_bLocked =
false;
3261 catch(
const io::WrongFormatException& )
3268 catch(
const uno::Exception& )
3271 catch(
const uno::Exception& )
3273 pImpl->m_bMSOLockFileCreated =
false;
3281 uno::Reference< io::XInputStream > xInToClose =
pImpl->xInputStream;
3282 uno::Reference< io::XOutputStream > xOutToClose;
3283 if (
pImpl->xStream.is() )
3285 xOutToClose =
pImpl->xStream->getOutputStream();
3288 if (
pImpl->xStream ==
pImpl->m_xLockingStream )
3289 pImpl->m_xLockingStream.clear();
3296 if (
pImpl->m_bSalvageMode )
3301 if ( xInToClose.is() )
3302 xInToClose->closeInput();
3303 if ( xOutToClose.is() )
3304 xOutToClose->closeOutput();
3306 catch (
const uno::Exception& )
3317 if (
pImpl->m_pSet )
3318 pImpl->m_pSet->ClearItem( SID_CONTENT );
3329 case INetProtocol::Ftp:
3330 case INetProtocol::Http:
3331 case INetProtocol::Https:
3332 pImpl->m_bRemote =
true;
3335 pImpl->m_bRemote =
GetName().startsWith(
"private:msgid");
3341 if (
pImpl->m_bRemote)
3342 pImpl->m_nStorOpenMode |= StreamMode::READ;
3348 if (
pImpl->aOrigURL.isEmpty())
3351 pImpl->aOrigURL = aNameP;
3352 std::unique_lock<std::recursive_mutex> chkEditLock;
3353 if (
pImpl->m_pCheckEditableWorkerMutex !=
nullptr)
3354 chkEditLock = std::unique_lock<std::recursive_mutex>(*(
pImpl->m_pCheckEditableWorkerMutex));
3355 pImpl->m_aLogicName = aNameP;
3356 pImpl->m_pURLObj.reset();
3357 if (chkEditLock.owns_lock())
3358 chkEditLock.unlock();
3366 return pImpl->aOrigURL.isEmpty() ?
pImpl->m_aLogicName :
pImpl->aOrigURL;
3372 if ( rNameP !=
pImpl->m_aName )
3374 pImpl->pTempFile.reset();
3376 if ( !
pImpl->m_aName.isEmpty() || !rNameP.isEmpty() )
3379 pImpl->m_aName = rNameP;
3380 pImpl->m_bTriedStorage =
false;
3381 pImpl->bIsStorage =
false;
3387 bool bUseInteractionHandler =
pImpl->bUseInteractionHandler;
3388 pImpl->bUseInteractionHandler =
false;
3390 pImpl->bUseInteractionHandler = bUseInteractionHandler;
3396 bool bUseInteractionHandler =
pImpl->bUseInteractionHandler;
3397 pImpl->bUseInteractionHandler =
false;
3399 std::unique_ptr<::utl::TempFileNamed> pTmpFile;
3400 if (
pImpl->pTempFile )
3402 pTmpFile = std::move(
pImpl->pTempFile);
3403 pImpl->m_aName.clear();
3410 if (
pImpl->pTempFile )
3412 pImpl->pTempFile->EnableKillingFile();
3413 pImpl->pTempFile.reset();
3415 pImpl->pTempFile = std::move( pTmpFile );
3416 if (
pImpl->pTempFile )
3417 pImpl->m_aName =
pImpl->pTempFile->GetFileName();
3421 pTmpFile->EnableKillingFile();
3425 pImpl->bUseInteractionHandler = bUseInteractionHandler;
3431 pImpl->m_pSet = pInSet;
3432 pImpl->m_pFilter = std::move(pFilter);
3433 pImpl->m_aLogicName = rName;
3434 pImpl->m_nStorOpenMode = nOpenMode;
3438SfxMedium::SfxMedium(
const OUString &rName,
const OUString &rReferer,
StreamMode nOpenMode, std::shared_ptr<const SfxFilter> pFilter,
const std::shared_ptr<SfxItemSet>& pInSet) :
3441 pImpl->m_pSet = pInSet;
3443 if (s.
GetItem(SID_REFERER) ==
nullptr) {
3446 pImpl->m_pFilter = std::move(pFilter);
3447 pImpl->m_aLogicName = rName;
3448 pImpl->m_nStorOpenMode = nOpenMode;
3456 pImpl->m_pSet.reset( pParams );
3460 OUString aFilterProvider, aFilterName;
3463 if ((pItem =
pImpl->m_pSet->GetItemIfSet(SID_FILTER_PROVIDER)))
3464 aFilterProvider = pItem->
GetValue();
3466 if ((pItem =
pImpl->m_pSet->GetItemIfSet(SID_FILTER_NAME)))
3470 if (aFilterProvider.isEmpty())
3478 pImpl->m_pCustomFilter = std::make_shared<SfxFilter>(aFilterProvider, aFilterName);
3482 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(
pImpl->m_pSet.get(), SID_DOC_SALVAGE,
false);
3486 if ( !pSalvageItem->
GetValue().isEmpty() )
3491 const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(
pImpl->m_pSet.get(), SID_FILE_NAME,
false);
3492 if (!pFileNameItem)
throw uno::RuntimeException();
3494 if ( !aNewTempFileURL.isEmpty() )
3497 pImpl->m_pSet->ClearItem( SID_INPUTSTREAM );
3498 pImpl->m_pSet->ClearItem( SID_STREAM );
3499 pImpl->m_pSet->ClearItem( SID_CONTENT );
3503 SAL_WARN(
"sfx.doc",
"Can not create a new temporary file for crash recovery!" );
3508 const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(
pImpl->m_pSet.get(), SID_DOC_READONLY,
false);
3509 if ( pReadOnlyItem && pReadOnlyItem->
GetValue() )
3510 pImpl->m_bOriginallyLoadedReadOnly =
true;
3512 const SfxStringItem* pFileNameItem = SfxItemSet::GetItem<SfxStringItem>(
pImpl->m_pSet.get(), SID_FILE_NAME,
false);
3513 if (!pFileNameItem)
throw uno::RuntimeException();
3515 pImpl->m_nStorOpenMode =
pImpl->m_bOriginallyLoadedReadOnly
3522 static constexpr OUStringLiteral
sStream(
u"Stream");
3523 static constexpr OUStringLiteral
sInputStream(
u"InputStream");
3532SfxMedium::SfxMedium(
const uno::Reference < embed::XStorage >& rStor,
const OUString& rBaseURL,
const std::shared_ptr<SfxItemSet>& p ) :
3540 pImpl->xStorage = rStor;
3541 pImpl->bDisposeStorage =
false;
3550SfxMedium::SfxMedium(
const uno::Reference < embed::XStorage >& rStor,
const OUString& rBaseURL,
const OUString &rTypeName,
const std::shared_ptr<SfxItemSet>& p ) :
3557 pImpl->xStorage = rStor;
3558 pImpl->bDisposeStorage =
false;
3576 if( !
pImpl->bIsTemp ||
pImpl->m_aName.isEmpty() )
3580 if ( osl::FileBase::getFileURLFromSystemPath(
pImpl->m_aName, aTemp )
3581 != osl::FileBase::E_None )
3583 SAL_WARN(
"sfx.doc",
"Physical name not convertible!");
3586 if ( !::utl::UCBContentHelper::Kill( aTemp ) )
3588 SAL_WARN(
"sfx.doc",
"Couldn't remove temporary file!");
3594 return pImpl->m_aLogicName;
3599 std::unique_lock<std::recursive_mutex> chkEditLock;
3600 if (
pImpl->m_pCheckEditableWorkerMutex !=
nullptr)
3601 chkEditLock = std::unique_lock<std::recursive_mutex>(*(
pImpl->m_pCheckEditableWorkerMutex));
3603 if (!
pImpl->m_pURLObj)
3606 pImpl->m_pURLObj->SetMark(
u"");
3609 return *
pImpl->m_pURLObj;
3614 pImpl->aExpireTime = rDateTime;
3626 return pImpl->wLoadTargetFrame;
3631 pImpl->m_xInputStreamToLoadFrom = xInputStream;
3632 pImpl->m_bInputStreamIsReadOnly = bIsReadOnly;
3637 pImpl->wLoadTargetFrame = pFrame;
3643 pImpl->xStorage = rStor;
3650 pImpl->m_pSet = std::make_shared<SfxAllItemSet>(
SfxGetpApp()->GetPool() );
3651 return *
pImpl->m_pSet;
3657 if( !
pImpl->xAttributes.is() )
3665 Any aAny =
pImpl->aContent.getPropertyValue(
"MediaType");
3666 OUString aContentType;
3667 aAny >>= aContentType;
3669 pImpl->xAttributes->Append(
SvKeyValue(
"content-type", aContentType ) );
3671 catch (
const css::uno::Exception& )
3677 return pImpl->xAttributes.get();
3682 if ( !
pImpl->xInputStream.is() )
3684 return pImpl->xInputStream;
3690 if ( ( !_bNoReload || !
pImpl->m_bVersionsAlreadyLoaded ) && !
pImpl->aVersions.hasElements() &&
3693 uno::Reference < document::XDocumentRevisionListPersistence > xReader =
3699 catch (
const uno::Exception& )
3704 if ( !
pImpl->m_bVersionsAlreadyLoaded )
3705 pImpl->m_bVersionsAlreadyLoaded =
true;
3707 return pImpl->aVersions;
3712 uno::Reference < document::XDocumentRevisionListPersistence > xReader =
3716 return xReader->load( xStorage );
3718 catch (
const uno::Exception& )
3722 return uno::Sequence < util::RevisionTag >();
3731 std::vector<sal_uInt32> aLongs;
3733 for (
const auto& rVersion : std::as_const(
pImpl->aVersions) )
3735 sal_uInt32 nVer =
static_cast<sal_uInt32
>(
o3tl::toInt32(rVersion.Identifier.subView(7)));
3737 for (
n=0;
n<aLongs.size(); ++
n )
3738 if ( nVer<aLongs[
n] )
3741 aLongs.insert( aLongs.begin()+
n, nVer );
3744 std::vector<sal_uInt32>::size_type nKey;
3745 for ( nKey=0; nKey<aLongs.size(); ++nKey )
3746 if ( aLongs[nKey] > nKey+1 )
3749 OUString aRevName =
"Version" + OUString::number( nKey + 1 );
3751 rRevision.Identifier = aRevName;
3757 if ( !
pImpl->aVersions.hasElements() )
3760 auto pVersion = std::find_if(std::cbegin(
pImpl->aVersions), std::cend(
pImpl->aVersions),
3761 [&rName](
const auto& rVersion) { return rVersion.Identifier == rName; });
3762 if (pVersion != std::cend(
pImpl->aVersions))
3764 auto nIndex =
static_cast<sal_Int32
>(std::distance(std::cbegin(
pImpl->aVersions), pVersion));
3771 if ( rMedium.
pImpl->aVersions.hasElements() )
3785 if ( !
pImpl->aVersions.hasElements() )
3788 uno::Reference < document::XDocumentRevisionListPersistence > xWriter =
3794 catch (
const uno::Exception& )
3802 bool bReadOnly =
pImpl->m_pFilter && (
pImpl->m_pFilter->GetFilterFlags() & SfxFilterFlags::OPENREADONLY);
3821 return pImpl->m_bOriginallyReadOnly;
3826 pImpl->m_bOriginallyReadOnly = val;
3831 return pImpl->m_bOriginallyLoadedReadOnly;
3838 bool bResult =
false;
3840 ::osl::DirectoryItem aDirItem;
3841 if ( ::osl::DirectoryItem::get(
aURL, aDirItem ) == ::osl::FileBase::E_None )
3843 ::osl::FileStatus aFileStatus( osl_FileStatus_Mask_Attributes );
3844 if ( aDirItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None
3845 && aFileStatus.isValid( osl_FileStatus_Mask_Attributes ) )
3847 sal_uInt64
nAttributes = aFileStatus.getAttributes();
3850 osl_File_Attribute_GrpWrite |
3851 osl_File_Attribute_OthWrite |
3852 osl_File_Attribute_ReadOnly);
3854 osl_File_Attribute_OwnRead);
3856 bResult = ( osl::File::setAttributes(
aURL,
nAttributes ) == ::osl::FileBase::E_None );
3866OUString GetLogicBase(
const INetURLObject& rURL, std::unique_ptr<SfxMedium_Impl>
const & pImpl)
3868 OUString aLogicBase;
3870#if HAVE_FEATURE_MACOSX_SANDBOX
3878 if (!pImpl->m_bHasEmbeddedObjects
3879 && rURL.
GetProtocol() == INetProtocol::File && !pImpl->m_pInStream)
3883 aURL.removeSegment();
3895 if (
pImpl->pTempFile )
3900 pImpl->pTempFile.reset();
3901 pImpl->m_aName.clear();
3905 pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
3906 pImpl->pTempFile->EnableKillingFile();
3907 pImpl->m_aName =
pImpl->pTempFile->GetFileName();
3908 OUString aTmpURL =
pImpl->pTempFile->GetURL();
3909 if (
pImpl->m_aName.isEmpty() || aTmpURL.isEmpty() )
3915 if ( !(
pImpl->m_nStorOpenMode & StreamMode::TRUNC) )
3917 bool bTransferSuccess =
false;
3927 uno::Reference< css::ucb::XCommandEnvironment > xComEnv;
3935 OUString sMimeType =
pImpl->getFilterMimeType();
3938 bTransferSuccess =
true;
3941 catch(
const uno::Exception& )
3944 if ( bTransferSuccess )
3951 if ( !bTransferSuccess &&
pImpl->m_pInStream )
3956 if (
pImpl->m_pOutStream )
3958 std::unique_ptr<char[]> pBuf(
new char [8192]);
3961 pImpl->m_pInStream->Seek(0);
3962 pImpl->m_pOutStream->Seek(0);
3966 sal_uInt32 nRead =
pImpl->m_pInStream->ReadBytes(pBuf.get(), 8192);
3967 nErr =
pImpl->m_pInStream->GetError();
3968 pImpl->m_pOutStream->WriteBytes( pBuf.get(), nRead );
3971 bTransferSuccess =
true;
3980 bTransferSuccess =
true;
3984 if ( !bTransferSuccess )
3998 pImpl->pTempFile.reset();
4001 pImpl->pTempFile.reset(new ::utl::TempFileNamed(&aLogicBase));
4002 pImpl->pTempFile->EnableKillingFile();
4003 pImpl->m_aName =
pImpl->pTempFile->GetFileName();
4004 if (
pImpl->m_aName.isEmpty() )
4015 const css::uno::Reference<css::frame::XModel>& xModel,
bool bHasValidDocumentSignature,
4016 const Reference<XCertificate>& xCertificate)
4018 bool bChanges =
false;
4022 SAL_WARN(
"sfx.doc",
"The medium must be closed by the signer!");
4029 uno::Reference< security::XDocumentDigitalSignatures > xSigner(
4030 security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
4032 auto xModelSigner =
dynamic_cast<sfx2::DigitalSignatures*
>(xSigner.get());
4038 uno::Reference< embed::XStorage > xWriteableZipStor;
4046 if ( !
pImpl->xStream.is() )
4047 throw uno::RuntimeException();
4054 catch (
const io::IOException&)
4062 if ( !xWriteableZipStor.is() && bODF )
4063 throw uno::RuntimeException();
4065 uno::Reference< embed::XStorage > xMetaInf;
4066 if (xWriteableZipStor.is() && xWriteableZipStor->hasByName(
"META-INF"))
4068 xMetaInf = xWriteableZipStor->openStorageElement(
4070 embed::ElementModes::READWRITE );
4071 if ( !xMetaInf.is() )
4072 throw uno::RuntimeException();
4079 uno::Reference< io::XStream >
xStream;
4081 xStream.set(xMetaInf->openStreamElement(xSigner->getDocumentContentSignatureDefaultStreamName(), embed::ElementModes::READWRITE), uno::UNO_SET_THROW);
4083 bool bSuccess = xModelSigner->SignModelWithCertificate(
4088 uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
4089 xTransact->commit();
4090 xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
4091 xTransact->commit();
4098 else if (xWriteableZipStor.is())
4101 uno::Reference<io::XStream>
xStream;
4104 bool bSuccess = xModelSigner->SignModelWithCertificate(
4109 uno::Reference<embed::XTransactedObject> xTransact(xWriteableZipStor, uno::UNO_QUERY_THROW);
4110 xTransact->commit();
4122 if (xModelSigner->SignModelWithCertificate(
4123 xModel, xCertificate, uno::Reference<embed::XStorage>(),
xStream))
4128 catch (
const uno::Exception& )
4130 SAL_WARN(
"sfx.doc",
"Couldn't use signing functionality!" );
4141 bool bSignScriptingContent,
4142 bool bHasValidDocumentSignature,
4143 const OUString& aSignatureLineId,
4144 const Reference<XCertificate>& xCert,
4145 const Reference<XGraphic>& xValidGraphic,
4146 const Reference<XGraphic>& xInvalidGraphic,
4147 const OUString& aComment)
4149 bool bChanges =
false;
4153 SAL_WARN(
"sfx.doc",
"The medium must be closed by the signer!");
4160 uno::Reference< security::XDocumentDigitalSignatures > xSigner(
4161 security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
4164 xSigner->setParentWindow(pDialogParent->
GetXWindow());
4166 uno::Reference< embed::XStorage > xWriteableZipStor;
4174 if ( !
pImpl->xStream.is() )
4175 throw uno::RuntimeException();
4182 catch (
const io::IOException&)
4190 if ( !xWriteableZipStor.is() && bODF )
4191 throw uno::RuntimeException();
4193 uno::Reference< embed::XStorage > xMetaInf;
4194 if (xWriteableZipStor.is() && xWriteableZipStor->hasByName(
"META-INF"))
4196 xMetaInf = xWriteableZipStor->openStorageElement(
4198 embed::ElementModes::READWRITE );
4199 if ( !xMetaInf.is() )
4200 throw uno::RuntimeException();
4203 if ( bSignScriptingContent )
4207 uno::Reference< io::XStream >
xStream(
4208 xMetaInf->openStreamElement( xSigner->getScriptingContentSignatureDefaultStreamName(),
4209 embed::ElementModes::READWRITE ),
4210 uno::UNO_SET_THROW );
4215 OUString aDocSigName = xSigner->getDocumentContentSignatureDefaultStreamName();
4216 if ( !aDocSigName.isEmpty() && xMetaInf->hasByName( aDocSigName ) )
4217 xMetaInf->removeElement( aDocSigName );
4219 uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
4220 xTransact->commit();
4221 xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
4222 xTransact->commit();
4234 uno::Reference< io::XStream >
xStream;
4236 xStream.set(xMetaInf->openStreamElement(xSigner->getDocumentContentSignatureDefaultStreamName(), embed::ElementModes::READWRITE), uno::UNO_SET_THROW);
4238 bool bSuccess =
false;
4240 bSuccess = xSigner->signSignatureLine(
4242 xValidGraphic, xInvalidGraphic, aComment);
4249 uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
4250 xTransact->commit();
4251 xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
4252 xTransact->commit();
4259 else if (xWriteableZipStor.is())
4262 uno::Reference<io::XStream>
xStream;
4264 bool bSuccess =
false;
4267 bSuccess = xSigner->signSignatureLine(
4269 xCert, xValidGraphic, xInvalidGraphic, aComment);
4274 bSuccess =xSigner->signDocumentContent(
4280 uno::Reference<embed::XTransactedObject> xTransact(xWriteableZipStor, uno::UNO_QUERY_THROW);
4281 xTransact->commit();
4293 if (xSigner->signDocumentContent(uno::Reference<embed::XStorage>(),
xStream))
4298 catch (
const uno::Exception& )
4300 SAL_WARN(
"sfx.doc",
"Couldn't use signing functionality!" );
4313 return pImpl->m_nSignatureState;
4324 pImpl->m_bHasEmbeddedObjects = bHasEmbeddedObjects;
4329 return pImpl->xStorage.is();
4334 return pImpl->m_pInStream ||
pImpl->m_pOutStream ||
pImpl->xStorage.is();
4341 if ( !
aURL.empty() )
4343 size_t nPrefixLen =
aURL.rfind(
'.' );
4344 std::u16string_view aExt = ( nPrefixLen == std::u16string_view::npos ) ? std::u16string_view() :
aURL.substr( nPrefixLen );
4346 OUString aNewTempFileURL = ::utl::CreateTempURL(
u"",
true, aExt );
4347 if ( !aNewTempFileURL.isEmpty() )
4358 uno::Reference< css::ucb::XCommandEnvironment > xComEnv;
4364 NameClash::OVERWRITE );
4365 aResult = aNewTempFileURL;
4367 catch(
const uno::Exception& )
4378 bool bResult =
false;
4380 if ( xHandler.is() )
4384 uno::Sequence< uno::Reference< task::XInteractionContinuation > > aContinuations( bAllowAbort ? 2 : 1 );
4385 auto pContinuations = aContinuations.getArray();
4388 pContinuations[ 0 ] = pApprove.get();
4393 pContinuations[ 1 ] = pAbort.get();
4397 bResult = pApprove->wasSelected();
4411 OUString aOrigURL =
pImpl->m_aLogicName;
4413 if ( !aOrigURL.isEmpty() )
4415 sal_Int32 nPrefixLen = aOrigURL.lastIndexOf(
'.' );
4416 std::u16string_view aExt = (nPrefixLen == -1)
4417 ? std::u16string_view()
4418 : aOrigURL.subView(nPrefixLen);
4419 OUString aNewURL = ::utl::CreateTempURL(
u"",
true, aExt );
4423 if ( !aNewURL.isEmpty() )
4425 uno::Reference< embed::XStorage > xStorage =
GetStorage();
4426 uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY );
4428 if ( xOptStorage.is() )
4437 bool bWasReadonly =
false;
4439 const SfxBoolItem* pReadOnlyItem = SfxItemSet::GetItem<SfxBoolItem>(
pImpl->m_pSet.get(), SID_DOC_READONLY,
false);
4440 if ( pReadOnlyItem && pReadOnlyItem->
GetValue() )
4441 bWasReadonly =
true;
4449 if (
pImpl->xStream.is() )
4453 xOptStorage->writeAndAttachToStream(
pImpl->xStream );
4454 pImpl->xStorage = xStorage;
4457 catch(
const uno::Exception& )
4468 if ( aResult.isEmpty() )
4474 pImpl->xStorage = xStorage;
4486 bool bResult =
false;
4487 OUString aOrigURL =
pImpl->m_aLogicName;
4489 if ( !
aURL.isEmpty() && !aOrigURL.isEmpty() )
4491 uno::Reference< embed::XStorage > xStorage =
GetStorage();
4492 uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY );
4506 if (
pImpl->xStream.is() )
4510 uno::Reference< io::XTruncate > xTruncate(
pImpl->xStream, uno::UNO_QUERY_THROW );
4511 xTruncate->truncate();
4512 if ( xOptStorage.is() )
4513 xOptStorage->writeAndAttachToStream(
pImpl->xStream );
4514 pImpl->xStorage = xStorage;
4517 catch(
const uno::Exception& )
4527 pImpl->xStorage = xStorage;
4536 pImpl->m_bInCheckIn = bInCheckIn;
4541 return pImpl->m_bInCheckIn;
4547 return pImpl->m_pCheckEditableWorkerMutex;
4553 pImpl->m_pReloadEvent = pEvent;
4559 return pImpl->m_pReloadEvent;
4565 if (!
pImpl->m_bNotifyWhenEditable)
4570 if (
pImpl->m_pCheckEditableWorkerMutex ==
nullptr)
4572 pImpl->m_pCheckEditableWorkerMutex = std::make_shared<std::recursive_mutex>();
4573 if (
pImpl->m_pCheckEditableWorkerMutex ==
nullptr)
4577 pImpl->m_pIsDestructed = std::make_shared<bool>(
false);
4578 if (
pImpl->m_pIsDestructed ==
nullptr)
4584 bool bAddNewEntry =
false;
4587 std::shared_ptr<comphelper::ThreadTaskTag> pTag
4589 if (pTag !=
nullptr)
4592 bAddNewEntry =
true;
4594 std::make_unique<CheckReadOnlyTask>(pTag));
4598 bAddNewEntry =
true;
4602 std::shared_ptr<ReadOnlyMediumEntry> newEntry = std::make_shared<ReadOnlyMediumEntry>(
4603 pImpl->m_pCheckEditableWorkerMutex,
pImpl->m_pIsDestructed);
4605 if (newEntry !=
nullptr)
4616 if (
pImpl->m_pCheckEditableWorkerMutex !=
nullptr)
4618 std::unique_lock<std::recursive_mutex>
lock(*(
pImpl->m_pCheckEditableWorkerMutex));
4620 if (
pImpl->m_pReloadEvent !=
nullptr)
4626 pImpl->m_pReloadEvent =
nullptr;
4629 if (
pImpl->m_pIsDestructed !=
nullptr)
4631 *(
pImpl->m_pIsDestructed) =
true;
4632 pImpl->m_pIsDestructed =
nullptr;
4644 if (pMed ==
nullptr)
4652 OUString aDocumentURL
4655 = new ::ucbhelper::InteractionRequest(
uno::Any(document::ReloadEditableRequest(
4656 OUString(), uno::Reference<uno::XInterface>(), aDocumentURL)));
4657 if (xInteractionRequestImpl !=
nullptr)
4659 uno::Sequence<uno::Reference<task::XInteractionContinuation>> aContinuations{
4660 new ::ucbhelper::InteractionAbort(xInteractionRequestImpl.get()),
4661 new ::ucbhelper::InteractionApprove(xInteractionRequestImpl.get())
4663 xInteractionRequestImpl->setContinuations(aContinuations);
4664 xHandler->handle(xInteractionRequestImpl);
4666 = xInteractionRequestImpl->getSelection();
4667 if (uno::Reference<task::XInteractionApprove>(xSelected.get(), uno::UNO_QUERY).is())
4672 if (pFrame->GetObjectShell()->GetMedium() == pMed)
4677 pFrame->GetDispatcher()->Execute(SID_RELOAD);
4688#if !HAVE_FEATURE_MULTIUSER_ENVIRONMENT
4689 bool bCanReload =
true;
4691 bool bCanReload =
false;
4694 osl::DirectoryItem rItem;
4695 auto nError1 = osl::DirectoryItem::get(aLockFile.
GetURL(), rItem);
4696 if (nError1 == osl::FileBase::E_None)
4702 catch (
const io::WrongFormatException&)
4707 catch (
const uno::Exception&)
4714 = aOwnData[LockFileComponent::SYSUSERNAME] ==
aData[LockFileComponent::SYSUSERNAME];
4716 && aOwnData[LockFileComponent::LOCALHOST] ==
aData[LockFileComponent::LOCALHOST]
4717 && aOwnData[LockFileComponent::USERURL] ==
aData[LockFileComponent::USERURL])
4723 else if (nError1 == osl::FileBase::E_NOENT)
4733 catch (
const io::WrongFormatException&)
4740 catch (
const uno::Exception&)
4746 catch (
const uno::Exception&)
4755void CheckReadOnlyTask::doWork()
4762 std::unique_lock<std::mutex> termLock(
m_xListener->mMutex);
4763 if (
m_xListener->mCond.wait_for(termLock, std::chrono::seconds(60),
4764 [
this] { return m_xListener->bIsTerminated; }))
4773 auto [pMed, roEntry] = *it;
4782 globalLock.unlock();
4784 auto checkForErase = [](
SfxMedium* pMed,
const std::shared_ptr<ReadOnlyMediumEntry>& roEntry) ->
bool
4786 if (pMed ==
nullptr || roEntry ==
nullptr || roEntry->_pMutex ==
nullptr
4787 || roEntry->_pIsDestructed ==
nullptr)
4790 std::unique_lock<std::recursive_mutex> medLock(*(roEntry->_pMutex));
4796 if (aFile.open(osl_File_OpenFlag_Write) != osl::FileBase::E_None)
4802 if (aFile.close() != osl::FileBase::E_None)
4814 if (checkForErase(it->first, it->second))
PropertiesInfo aProperties
SfxApplication * SfxGetpApp()
constexpr OUStringLiteral sInputStream
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
constexpr OUStringLiteral sStream
void TransformParameters(sal_uInt16 nSlotId, const uno::Sequence< beans::PropertyValue > &rArgs, SfxAllItemSet &rSet, const SfxSlot *pSlot)
const sal_uInt16 nVersion
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
const OUString & GetValue() const
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool isAnyKnownWebDAVScheme() const
bool hasExtension() const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString getExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
OUString GetMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetURLNoMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetPartBeforeLastName() const
bool insertName(std::u16string_view rTheName, bool bAppendFinalSlash=false, sal_Int32 nIndex=LAST_SEGMENT, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
INetProtocol GetProtocol() const
bool setExtension(std::u16string_view rTheExtension, sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString getFSysPath(FSysStyle eStyle, sal_Unicode *pDelimiter=nullptr) const
SfxFilterMatcher & GetFilterMatcher()
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4EA(const OUString &rEA, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
static OUString GetTypeFromStorage(const SotStorage &rStg)
sal_Int16 GetValue() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
uno::Reference< task::XInteractionHandler > xInteraction
SignatureState m_nSignatureState
ErrCode nLastStorageError
StreamMode m_nStorOpenMode
std::shared_ptr< std::recursive_mutex > m_pCheckEditableWorkerMutex
uno::Reference< io::XStream > xStream
::ucbhelper::Content aContent
SfxMedium_Impl & operator=(const SfxMedium_Impl &)=delete
bool m_bMSOLockFileCreated
bool m_bNotifyWhenEditable
std::shared_ptr< bool > m_pIsDestructed
SvKeyValueIteratorRef xAttributes
bool m_bInputStreamIsReadOnly
uno::Reference< io::XInputStream > xInputStream
SfxFrameWeakRef wLoadTargetFrame
bool m_bHasEmbeddedObjects
uno::Reference< embed::XStorage > xStorage
util::DateTime m_aDateTime
uno::Reference< io::XStream > m_xLockingStream
std::shared_ptr< const SfxFilter > m_pFilter
std::unique_ptr<::utl::TempFileNamed > pTempFile
ImplSVEvent * m_pReloadEvent
bool m_bVersionsAlreadyLoaded
std::unique_ptr< INetURLObject > m_pURLObj
svtools::AsynchronLink aDoneLink
bool bUseInteractionHandler
bool m_bOriginallyReadOnly
std::shared_ptr< SfxItemSet > m_pSet
uno::Sequence< util::RevisionTag > aVersions
uno::Reference< io::XInputStream > m_xInputStreamToLoadFrom
bool bStorageBasedOnInStream
bool m_bOriginallyLoadedReadOnly
OUString getFilterMimeType() const
std::shared_ptr< const SfxFilter > m_pCustomFilter
std::unique_ptr< SvStream > m_pInStream
uno::Sequence< beans::PropertyValue > m_aArgs
bool m_bDisableUnlockWebDAV
uno::Reference< embed::XStorage > m_xZipStorage
SfxMedium_Impl(const SfxMedium_Impl &)=delete
std::unique_ptr< SvStream > m_pOutStream
bool CheckCanGetLockfile() const
SAL_DLLPRIVATE void GetLockingStream_Impl()
SfxFrame * GetLoadTargetFrame() const
ErrCode const & GetLastStorageCreationState() const
void CreateTempFileNoCopy()
SAL_DLLPRIVATE void CreateFileStream()
void SetOpenMode(StreamMode nStorOpen, bool bDontClose=false)
const std::shared_ptr< const SfxFilter > & GetFilter() const
void DisableFileSync(bool bDisableFileSync)
Lets Transfer_Impl() not fsync the output file.
SAL_DLLPRIVATE void CloseAndReleaseStreams_Impl()
void SetError(ErrCode nError)
void Close(bool bInDestruction=false)
SAL_DLLPRIVATE void CloseInStream_Impl(bool bInDestruction=false)
void setStreamToLoadFrom(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bIsReadOnly)
OUString GetBaseURL(bool bForSaving=false)
SAL_DLLPRIVATE void SetEncryptionDataToStorage_Impl()
SAL_DLLPRIVATE bool TryDirectTransfer(const OUString &aURL, SfxItemSet const &aTargetSet)
void SetHasEmbeddedObjects(bool bHasEmbeddedObjects)
bool IsOriginallyLoadedReadOnly() const
const INetURLObject & GetURLObject() const
void UseInteractionHandler(bool)
SAL_DLLPRIVATE bool IsUpdatePickList() const
css::util::DateTime const & GetInitFileDate(bool bIgnoreOldValue)
SAL_DLLPRIVATE void SetStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xNewStorage)
SfxItemSet & GetItemSet() const
void Download(const Link< void *, void > &aLink=Link< void *, void >())
LockFileResult LockOrigFileOnDemand(bool bLoading, bool bNoUI, bool bTryIgnoreLockFile=false, LockFileEntry *pLockData=nullptr)
SAL_DLLPRIVATE void DoInternalBackup_Impl(const ::ucbhelper::Content &aOriginalContent)
SAL_DLLPRIVATE void SetPhysicalName_Impl(const OUString &rName)
SAL_DLLPRIVATE SignatureState GetCachedSignatureState_Impl() const
bool IsSkipImages() const
ErrCode GetErrorCode() const
SAL_DLLPRIVATE void SetUpdatePickList(bool)
void SetDoneLink(const Link< void *, void > &rLink)
SAL_DLLPRIVATE void CanDisposeStorage_Impl(bool bDisposeStorage)
void SetInCheckIn(bool bInCheckIn)
SAL_DLLPRIVATE void SaveVersionList_Impl()
SAL_DLLPRIVATE bool UseBackupToRestore_Impl(::ucbhelper::Content &aOriginalContent, const css::uno::Reference< css::ucb::XCommandEnvironment > &xComEnv)
bool IsOriginallyReadOnly() const
bool ShowLockFileProblemDialog(MessageDlg nWhichDlg)
SAL_DLLPRIVATE void DoBackup_Impl(bool bForceUsingBackupPath)
SAL_DLLPRIVATE OUString const & GetBackup_Impl()
SAL_DLLPRIVATE bool TransferVersionList_Impl(SfxMedium const &rMedium)
StreamMode GetOpenMode() const
static sal_uInt32 CreatePasswordToModifyHash(std::u16string_view aPasswd, bool bWriter)
std::unique_ptr< SfxMedium_Impl > pImpl
const OUString & GetOrigURL() const
SAL_DLLPRIVATE void SetLongName(const OUString &rName)
void SetName(const OUString &rName, bool bSetOrigURL=false)
const css::uno::Sequence< css::util::RevisionTag > & GetVersionList(bool _bNoReload=false)
const OUString & GetName() const
SAL_DLLPRIVATE bool SignDocumentContentUsingCertificate(const css::uno::Reference< css::frame::XModel > &xModel, bool bHasValidDocumentSignature, const css::uno::Reference< css::security::XCertificate > &xCertificate)
void DisableUnlockWebDAV(bool bDisableUnlockWebDAV=true)
const std::shared_ptr< std::recursive_mutex > & GetCheckEditableMutex() const
SAL_DLLPRIVATE void StorageBackup_Impl()
void CancelCheckEditableEntry(bool bRemoveEvent=true)
void SetWarningError(ErrCode nWarningError)
bool SwitchDocumentToFile(const OUString &aURL)
static bool SetWritableForUserOnly(const OUString &aURL)
SAL_DLLPRIVATE bool HasStorage_Impl() const
static OUString CreateTempCopyWithExt(std::u16string_view aURL)
SAL_DLLPRIVATE SvKeyValueIterator * GetHeaderAttributes_Impl()
void UnlockFile(bool bReleaseLockStream)
SAL_DLLPRIVATE void TransactedTransferForFS_Impl(const INetURLObject &aSource, const INetURLObject &aDest, const css::uno::Reference< css::ucb::XCommandEnvironment > &xComEnv)
SAL_DLLPRIVATE bool WillDisposeStorageOnClose_Impl()
void CreateTempFile(bool bReplace=true)
SAL_DLLPRIVATE void SetCachedSignatureState_Impl(SignatureState nState)
virtual ~SfxMedium() override
static bool CallApproveHandler(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, const css::uno::Any &rRequest, bool bAllowAbort)
void SetOriginallyReadOnly(bool val)
const css::uno::Sequence< css::beans::PropertyValue > & GetArgs() const
SAL_DLLPRIVATE void SetIsRemote_Impl()
SAL_DLLPRIVATE void GetMedium_Impl()
SAL_DLLPRIVATE void RemoveVersion_Impl(const OUString &rVersion)
SAL_DLLPRIVATE const OUString & GetLongName() const
void SetFilter(const std::shared_ptr< const SfxFilter > &pFilter)
Does not take ownership of pFlt but pFlt needs to be around as long as the SfxMedium instance.
ShowLockResult ShowLockedDocumentDialog(const LockFileEntry &aData, bool bIsLoading, bool bOwnLock, bool bHandleSysLocked)
SAL_DLLPRIVATE void CloseStreams_Impl(bool bInDestruction=false)
void SetLoadTargetFrame(SfxFrame *pFrame)
css::uno::Reference< css::ucb::XContent > GetContent() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
SAL_DLLPRIVATE void SetExpired_Impl(const DateTime &rDateTime)
SAL_DLLPRIVATE bool IsPreview_Impl() const
SvStream * GetOutStream()
ImplSVEvent * GetWorkerReloadEvent() const
SAL_DLLPRIVATE void Transfer_Impl()
SAL_DLLPRIVATE void CloseOutStream_Impl()
css::uno::Reference< css::io::XInputStream > const & GetInputStream()
SAL_DLLPRIVATE void ClearBackup_Impl()
void SetWorkerReloadEvent(ImplSVEvent *pEvent)
void AddToCheckEditableWorkerList()
OUString SwitchDocumentToTempFile()
SAL_DLLPRIVATE void AddVersion_Impl(css::util::RevisionTag &rVersion)
void CheckFileDate(const css::util::DateTime &aInitDate)
SAL_DLLPRIVATE css::uno::Reference< css::embed::XStorage > const & GetZipStorageToSign_Impl(bool bReadOnly=true)
bool DocNeedsFileDateCheck() const
SAL_DLLPRIVATE bool StorageCommit_Impl()
SAL_DLLPRIVATE bool SignContents_Impl(weld::Window *pDialogParent, bool bSignScriptingContent, bool bHasValidDocumentSignature, const OUString &aSignatureLineId=OUString(), const css::uno::Reference< css::security::XCertificate > &xCert=css::uno::Reference< css::security::XCertificate >(), const css::uno::Reference< css::graphic::XGraphic > &xValidGraphic=css::uno::Reference< css::graphic::XGraphic >(), const css::uno::Reference< css::graphic::XGraphic > &xInvalidGraphic=css::uno::Reference< css::graphic::XGraphic >(), const OUString &aComment=OUString())
SAL_DLLPRIVATE void Init_Impl()
void SetArgs(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
SAL_DLLPRIVATE void CloseZipStorage_Impl()
ErrCode GetWarningError() const
const OUString & GetPhysicalName() const
css::uno::Reference< css::embed::XStorage > GetOutputStorage()
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
const css::uno::Any & GetValue() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static bool IsStorageFile(OUString const &rFileName)
bool IsOLEStorage() const
void SetSynchronMode(bool bTheSync=true)
static SvtFilterOptions & Get()
bool IsMSOLockFileCreationIsEnabled() const
const OUString & GetBackupPath() const
static sal_uInt16 GetXLHashAsUINT16(std::u16string_view aString, rtl_TextEncoding nEnc=RTL_TEXTENCODING_UTF8)
static sal_uInt32 GetWordHashAsUINT32(std::u16string_view aString)
static OUString GetODFVersionFromStorage(const css::uno::Reference< css::embed::XStorage > &xStorage)
static void SetCommonStorageEncryptionData(const css::uno::Reference< css::embed::XStorage > &xStorage, const css::uno::Sequence< css::beans::NamedValue > &aEncryptionData)
static css::uno::Reference< css::embed::XStorage > GetStorageFromURL(const OUString &aURL, sal_Int32 nStorageMode, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromInputStream(const OUString &aFormat, const css::uno::Reference< css::io::XInputStream > &xStream, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >(), bool bRepairStorage=false)
static css::uno::Reference< css::lang::XSingleServiceFactory > GetStorageFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromStream(const OUString &aFormat, const css::uno::Reference< css::io::XStream > &xStream, sal_Int32 nStorageMode=css::embed::ElementModes::READWRITE, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >(), bool bRepairStorage=false)
iterator erase(iterator it)
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
static ThreadPool & getSharedOptimalPool()
static std::shared_ptr< ThreadTaskTag > createThreadTaskTag()
void pushTask(std::unique_ptr< ThreadTask > pTask)
static css::uno::Reference< css::task::XInteractionRequest > CreateRequest(const css::uno::Any &aRequest, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &lContinuations)
rtl::Reference< comphelper::ConfigurationListener > m_xListener
LockFileEntry GetLockData()
bool OverwriteOwnLockFile()
void RemoveFileDirectly()
virtual void RemoveFile()
static LockFileEntry GenerateOwnEntry()
const OUString & GetURL() const
virtual void RemoveFile() override
static bool IsMSOSupportedFileFormat(std::u16string_view aURL)
css::uno::Any setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue)
void transferContent(const Content &rSourceContent, InsertOperation eOperation, const OUString &rTitle, const sal_Int32 nNameClashAction, const OUString &rMimeType=OUString(), bool bMajorVersion=false, const OUString &rCommentVersion=OUString(), OUString *pResultURL=nullptr, const OUString &rDocumentId=OUString()) const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
static bool create(const OUString &rURL, const css::uno::Reference< css::ucb::XCommandEnvironment > &rEnv, const css::uno::Reference< css::uno::XComponentContext > &rCtx, Content &rContent)
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
css::uno::Reference< css::ucb::XContent > get() const
css::uno::Reference< css::io::XInputStream > openStream()
void writeStream(const css::uno::Reference< css::io::XInputStream > &rStream, bool bReplaceExisting)
void EnableKillingFile(bool bEnable=true)
OUString const & GetURL() const
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
static std::mutex g_chkReadOnlyGlobalMutex
static std::unordered_map< SfxMedium *, std::shared_ptr< ReadOnlyMediumEntry > > g_newReadOnlyDocs
IMPL_STATIC_LINK(SfxMedium, ShowReloadEditableDialog, void *, p, void)
callback function, which is triggered by worker thread after successfully checking if the file is edi...
static bool g_bChkReadOnlyTaskRunning
static std::unordered_map< SfxMedium *, std::shared_ptr< ReadOnlyMediumEntry > > g_existingReadOnlyDocs
uno::Reference< task::XInteractionHandler2 > m_xHandler
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_IO_CANTREAD
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_NOTEXISTSPATH
#define ERRCODE_IO_CANTWRITE
#define ERRCODE_IO_NOTEXISTS
#define ERRCODE_IO_ALREADYEXISTS
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url)
Reference< XComponentContext > getProcessComponentContext()
css::uno::Sequence< css::beans::PropertyValue > InitPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
void removeElementAt(css::uno::Sequence< T > &_rSeq, sal_Int32 _nPos)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
std::shared_ptr< osl::Mutex > const & lock()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
UNOTOOLS_DLLPUBLIC css::uno::Reference< css::ucb::XCommandEnvironment > getDefaultCommandEnvironment()
bool GetEncryptionData_Impl(const SfxItemSet *pSet, uno::Sequence< beans::NamedValue > &o_rEncryptionData)
#define SFX_STREAM_READONLY
#define SFX_STREAM_READWRITE
#define ERRCODE_SFX_CANTCREATEBACKUP
const sal_Unicode *const aMimeType[]
constexpr OUStringLiteral ZIP_STORAGE_FORMAT_STRING
Reference< XModel > xModel