20#include <config_features.h>
30#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
31#include <com/sun/star/frame/XModel.hpp>
32#include <com/sun/star/frame/XModule.hpp>
33#include <com/sun/star/document/XFilter.hpp>
34#include <com/sun/star/document/XImporter.hpp>
35#include <com/sun/star/document/XExporter.hpp>
36#include <com/sun/star/packages/zip/ZipIOException.hpp>
37#include <com/sun/star/task/XInteractionHandler.hpp>
38#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
39#include <com/sun/star/document/MacroExecMode.hpp>
40#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
41#include <com/sun/star/beans/XPropertySetInfo.hpp>
42#include <com/sun/star/lang/XMultiServiceFactory.hpp>
43#include <com/sun/star/beans/PropertyValue.hpp>
44#include <com/sun/star/beans/XPropertySet.hpp>
45#include <com/sun/star/container/XNameAccess.hpp>
46#include <com/sun/star/embed/ElementModes.hpp>
47#include <com/sun/star/embed/EmbedStates.hpp>
48#include <com/sun/star/embed/XTransactedObject.hpp>
49#include <com/sun/star/embed/XEmbeddedObject.hpp>
50#include <com/sun/star/embed/XEmbedPersist.hpp>
51#include <com/sun/star/embed/XOptimizedStorage.hpp>
52#include <com/sun/star/embed/XEncryptionProtectedStorage.hpp>
53#include <com/sun/star/io/WrongFormatException.hpp>
54#include <com/sun/star/io/XTruncate.hpp>
55#include <com/sun/star/util/XModifiable.hpp>
56#include <com/sun/star/util/RevisionTag.hpp>
57#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
58#include <com/sun/star/text/XTextRange.hpp>
59#include <com/sun/star/xml/crypto/CipherID.hpp>
60#include <com/sun/star/xml/crypto/DigestID.hpp>
62#include <com/sun/star/document/XDocumentProperties.hpp>
63#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
91#include <officecfg/Office/Common.hxx>
92#include <osl/file.hxx>
108#include <sfx2/strings.hrc>
109#include <sfx2/sfxsids.hrc>
129using namespace ::
cppu;
137 css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
138 css::uno::Reference< css::frame::XGlobalEventBroadcaster > xModelCollection =
139 css::frame::theGlobalEventBroadcaster::get(xContext);
142 xModelCollection->insert(css::uno::Any(
xModel));
144 catch ( uno::Exception& )
146 SAL_WARN(
"sfx.doc",
"The document seems to be in the collection already!" );
172 bool bResult =
false;
175 const SfxUnoAnyItem* pEncryptionDataItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pSet, SID_ENCRYPTIONDATA,
false);
176 if ( pEncryptionDataItem )
178 pEncryptionDataItem->
GetValue() >>= o_rEncryptionData;
183 const SfxStringItem* pPasswordItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_PASSWORD,
false);
197 const OUString& aURL,
198 const uno::Reference< embed::XStorage >& xDocStorage,
199 const OUString& aStreamName )
201 bool bResult =
false;
204 uno::Reference< embed::XStorage > xVersion = xDocStorage->openStorageElement(
206 embed::ElementModes::READWRITE );
209 "The method must throw an exception if the storage can not be opened!" );
210 if ( !xVersion.is() )
211 throw uno::RuntimeException();
213 uno::Reference< io::XStream > xVerStream = xVersion->openStreamElement(
215 embed::ElementModes::READWRITE );
216 DBG_ASSERT( xVerStream.is(),
"The method must throw an exception if the storage can not be opened!" );
217 if ( !xVerStream.is() )
218 throw uno::RuntimeException();
220 uno::Reference< io::XOutputStream > xOutStream = xVerStream->getOutputStream();
221 uno::Reference< io::XTruncate > xTrunc( xOutStream, uno::UNO_QUERY_THROW );
223 uno::Reference< io::XInputStream > xTmpInStream =
226 assert( xTmpInStream.is() );
230 xOutStream->closeOutput();
232 uno::Reference< embed::XTransactedObject > xTransact( xVersion, uno::UNO_QUERY );
233 DBG_ASSERT( xTransact.is(),
"The storage must implement XTransacted interface!\n" );
234 if ( xTransact.is() )
239 catch( uno::Exception& )
251 OUString aTempURL = ::utl::CreateTempURL();
253 DBG_ASSERT( !aTempURL.isEmpty(),
"Can't create a temporary file!\n" );
254 if ( !aTempURL.isEmpty() )
258 uno::Reference< embed::XStorage > xTempStorage =
262 xStorage->copyToStorage( xTempStorage );
266 catch ( uno::Exception& )
268 SAL_WARN(
"sfx.doc",
"Creation of a storage copy is failed!" );
269 ::utl::UCBContentHelper::Kill( aTempURL );
289 sal_Int32
nVersion,
bool bTemplate )
const
291 uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY );
299 OUString aFullTypeName;
302 if ( nClipFormat == SotClipboardFormatId::NONE )
308 datatransfer::DataFlavor aDataFlavor;
310 if ( aDataFlavor.MimeType.isEmpty() )
315 xProps->setPropertyValue(
"MediaType",
uno::Any( aDataFlavor.MimeType ) );
317 catch( uno::Exception& )
329 uno::Sequence< beans::NamedValue > aEncryptionAlgs
331 {
"StartKeyGenerationAlgorithm", css::uno::Any(xml::crypto::DigestID::SHA1) },
332 {
"EncryptionAlgorithm", css::uno::Any(xml::crypto::CipherID::BLOWFISH_CFB_8) },
333 {
"ChecksumAlgorithm", css::uno::Any(xml::crypto::DigestID::SHA1_1K) }
341 uno::Reference<frame::XModule>
const xModule(
GetModel(), uno::UNO_QUERY);
342 bool const isBaseForm(xModule.is() &&
343 xModule->getIdentifier() ==
"com.sun.star.sdb.FormDesign");
344 SAL_INFO_IF(isBaseForm,
"sfx.doc",
"tdf#138209 force form export to ODF 1.2");
354 catch( uno::Exception& )
358 auto pEncryptionAlgs = aEncryptionAlgs.getArray();
359 pEncryptionAlgs[0].Value <<= xml::crypto::DigestID::SHA256;
360 pEncryptionAlgs[2].Value <<= xml::crypto::DigestID::SHA256_1K;
361 pEncryptionAlgs[1].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING;
369 uno::Reference< embed::XEncryptionProtectedStorage > xEncr( xStorage, uno::UNO_QUERY_THROW );
370 xEncr->setEncryptionAlgorithms( aEncryptionAlgs );
372 catch( uno::Exception& )
382 pImpl->m_xDocStorage.clear();
383 pImpl->m_bIsInit =
false;
389 bool bTypeMustBeSetAlready )
391 if (
pImpl->m_bIsInit )
394 pImpl->m_bIsInit =
true;
398 pImpl->m_xDocStorage = xStorage;
401 uno::Reference < beans::XPropertySet > xPropSet( xStorage, uno::UNO_QUERY_THROW );
402 Any a = xPropSet->getPropertyValue(
"MediaType");
404 if ( !(
a>>=aMediaType) || aMediaType.isEmpty() )
406 if ( bTypeMustBeSetAlready )
415 catch ( uno::Exception& )
417 SAL_WARN(
"sfx.doc",
"Can't check storage's mediatype!" );
421 pImpl->m_bCreateTempStor =
true;
473 pImpl->aMacroMode.allowMacroExecution();
481 uno::Sequence< beans::PropertyValue > aArgs;
483 sal_Int32
nLength = aArgs.getLength();
485 auto pArgs = aArgs.getArray();
488 xModel->attachResource( OUString(), aArgs );
501 const uno::Reference< io::XStream >& xStream,
502 const uno::Sequence< beans::PropertyValue >& rMediaDescr )
510 bool bResult =
false;
514 uno::Reference< embed::XStorage > xStorage =
517 if ( !xStorage.is() )
518 throw uno::RuntimeException();
529 uno::Reference<text::XTextRange> xInsertTextRange;
530 for (
const auto& rProp : rMediaDescr)
532 if (rProp.Name ==
"TextInsertModeRange")
534 rProp.Value >>= xInsertTextRange;
538 if (xInsertTextRange.is())
546 if (
pImpl->m_bIsInit )
547 pImpl->m_bIsInit =
false;
556 OSL_ENSURE(
pImpl->m_xDocStorage == xStorage,
"Wrong storage is used!" );
564 catch( uno::Exception& )
580 std::shared_ptr<const SfxFilter> pFilter = pMed->
GetFilter();
586 ( pTemplateItem && pTemplateItem->
GetValue() )
599 osl::FileBase::getFileURLFromSystemPath( pMed->
GetPhysicalName(), aBaseURL );
607 pImpl->bModelInitialized =
false;
609 if (pFilter && !pFilter->IsEnabled())
631 if (
pMedium->
GetFilter()->GetFilterFlags() & SfxFilterFlags::STARTPRESENTATION)
638 if (
GetError() ==
ERRCODE_NONE && bOwnStorageFormat && ( !pFilter || !( pFilter->GetFilterFlags() & SfxFilterFlags::STARONEFILTER ) ) )
640 uno::Reference< embed::XStorage > xStorage;
646 DBG_ASSERT( pFilter,
"No filter for storage found!" );
650 bool bWarnMediaTypeFallback =
false;
654 uno::Reference< beans::XPropertySet > xStorProps( xStorage, uno::UNO_QUERY_THROW );
655 xStorProps->getPropertyValue(
"MediaTypeFallbackUsed")
656 >>= bWarnMediaTypeFallback;
658 if ( pRepairPackageItem && pRepairPackageItem->
GetValue() )
665 bWarnMediaTypeFallback =
false;
668 if (bWarnMediaTypeFallback || !xStorage->getElementNames().hasElements())
671 catch( uno::Exception& )
681 pImpl->bModelInitialized =
false;
687 if ( !pTemplateItem || !pTemplateItem->
GetValue() )
712#if !HAVE_FEATURE_POPPLER
713 constexpr bool bUsePdfium =
true;
715 const bool bUsePdfium
718 const bool bPdfiumImport
723 pImpl->bModelInitialized =
false;
728 uno::Reference < beans::XPropertySet > xSet(
GetModel(), uno::UNO_QUERY );
729 static constexpr OUStringLiteral sLockUpdates(
u"LockUpdates");
730 bool bSetProperty =
true;
733 xSet->setPropertyValue( sLockUpdates,
Any(
true ) );
735 catch(
const beans::UnknownPropertyException& )
737 bSetProperty =
false;
744 xSet->setPropertyValue( sLockUpdates,
Any(
false ) );
746 catch(
const beans::UnknownPropertyException& )
776 css::uno::Reference < XPropertySetInfo > xProps = aContent.
getProperties();
779 static constexpr OUStringLiteral aAuthor(
u"Author" );
780 static constexpr OUStringLiteral aKeywords(
u"Keywords" );
781 static constexpr OUStringLiteral aSubject(
u"Subject" );
784 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
786 uno::Reference<document::XDocumentProperties> xDocProps
787 = xDPS->getDocumentProperties();
788 if ( xProps->hasPropertyByName( aAuthor ) )
791 if ( aAny >>= aValue )
792 xDocProps->setAuthor(aValue);
794 if ( xProps->hasPropertyByName( aKeywords ) )
797 if ( aAny >>= aValue )
798 xDocProps->setKeywords(
799 ::comphelper::string::convertCommaSeparated(aValue));
802 if ( xProps->hasPropertyByName( aSubject ) )
805 if ( aAny >>= aValue ) {
806 xDocProps->setSubject(aValue);
829 && !( pAsTempItem && pAsTempItem->
GetValue() )
830 && !( pPreviewItem && pPreviewItem->
GetValue() )
831 && !( pHiddenItem && pHiddenItem->
GetValue() ) )
839 bool bReconnectDde =
true;
840 if (pDdeReconnectItem)
841 bReconnectDde = pDdeReconnectItem->
GetValue();
863 if ( !
pData && (bTiledRendering || !pOptions) )
865 css::uno::Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
866 css::uno::Reference< XNameAccess > xFilterCFG;
867 if( xServiceManager.is() )
869 xFilterCFG.set( xServiceManager->createInstance(
"com.sun.star.document.FilterFactory"),
873 if( xFilterCFG.is() )
878 Sequence < PropertyValue > aProps;
879 Any aAny = xFilterCFG->getByName( pFilter->GetName() );
880 if ( aAny >>= aProps )
882 auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps),
883 [](
const PropertyValue& rProp) {
return rProp.Name ==
"UIComponent"; });
884 if (pProp != std::cend(aProps))
886 OUString aServiceName;
887 pProp->Value >>= aServiceName;
888 if( !aServiceName.isEmpty() )
903 Sequence< PropertyValue > rProperties;
907 rHandler->handle( pFORequest );
909 if ( !pFORequest->isAbort() )
913 pFORequest->getFilterOptions(),
917 if ( pFilterOptions )
937 catch( NoSuchElementException& )
979 pImpl->bIsSaving =
true;
988 uno::Reference<beans::XPropertySet>
const xProps(
GetMedium()->
GetStorage(), uno::UNO_QUERY);
994 uno::Reference<frame::XModule>
const xModule(
GetModel(), uno::UNO_QUERY);
995 bool const isBaseForm(xModule.is() &&
996 xModule->getIdentifier() ==
"com.sun.star.sdb.FormDesign");
997 SAL_INFO_IF(isBaseForm,
"sfx.doc",
"tdf#138209 force form export to ODF 1.2");
1007 catch (uno::Exception&)
1014 uno::Sequence< beans::NamedValue > aEncryptionData;
1025 catch( uno::Exception& )
1030 DBG_ASSERT( bOk,
"The root storage must allow to set common password!\n" );
1034#if HAVE_FEATURE_SCRIPTING
1043 DBG_ASSERT( xTmpStorage.is(),
"If a storage can not be created an exception must be thrown!\n" );
1044 if ( !xTmpStorage.is() )
1045 throw uno::RuntimeException();
1047 static constexpr OUStringLiteral aBasicStorageName(
u"Basic" );
1048 static constexpr OUStringLiteral aDialogsStorageName(
u"Dialogs" );
1050 GetMedium()->
GetStorage()->copyElementTo( aBasicStorageName, xTmpStorage, aBasicStorageName );
1052 GetMedium()->
GetStorage()->copyElementTo( aDialogsStorageName, xTmpStorage, aDialogsStorageName );
1057 pImpl->aBasicManager.setStorage( xTmpStorage );
1065 catch( uno::Exception& )
1094 ~LockUIGuard() { Unlock(); }
1109 pFrame->
Enable(m_bUnlock);
1112 m_bUnlock = !m_bUnlock;
1115 bool m_bUnlock =
false;
1121 static constexpr OUStringLiteral sPostfix(
u"_template");
1122 OUString sRes(aString);
1123 if (sRes.endsWith(sPostfix))
1124 sRes = sRes.copy(0, sRes.getLength() - sPostfix.getLength());
1152 std::shared_ptr<const SfxFilter> pFilter = rMedium.
GetFilter();
1157 SAL_WARN(
"sfx.doc",
"No filter set!");
1175 bool bNeedsDisconnectionOnFail =
false;
1177 bool bStoreToSameLocation =
false;
1180 bool bTryToPreserveScriptSignature =
false;
1182 bool bNoPreserveForOasis =
false;
1183 if ( bOwnSource && bOwnTarget
1191 bTryToPreserveScriptSignature =
true;
1192 if ( bTryToPreserveScriptSignature )
1197 OUString aODFVersion;
1200 uno::Reference < beans::XPropertySet > xPropSet(
GetStorage(), uno::UNO_QUERY_THROW );
1201 xPropSet->getPropertyValue(
"Version") >>= aODFVersion;
1203 catch( uno::Exception& )
1215 bNoPreserveForOasis = (
1224 && !rMedium.
GetName().equalsIgnoreAsciiCase(
"private:stream")
1231 bStoreToSameLocation =
true;
1257 if ( bStorageBasedSource && bStorageBasedTarget )
1278 if ( bNeedsDisconnectionOnFail
1293 else if ( !bStorageBasedSource && !bStorageBasedTarget )
1304 else if ( !bStorageBasedSource && bStorageBasedTarget )
1322 if ( bNeedsDisconnectionOnFail
1341 if ( bStorageBasedTarget )
1352 SAL_WARN(
"sfx.doc",
"SfxObjectShell::SaveTo_Impl: very early error return");
1358 if ( bStorageBasedTarget )
1371 if ( pFilt->GetServiceName() != rMedium.
GetFilter()->GetServiceName() )
1373 datatransfer::DataFlavor aDataFlavor;
1378 uno::Reference< beans::XPropertySet > xProps( rMedium.
GetStorage(), uno::UNO_QUERY_THROW );
1379 xProps->setPropertyValue(
"MediaType",
1380 uno::Any( aDataFlavor.MimeType ) );
1382 catch( uno::Exception& )
1393 bool bOldStat =
pImpl->bForbidReload;
1394 pImpl->bForbidReload =
true;
1397 LockUIGuard aLockUIGuard(
this);
1399 bool bCopyTo =
false;
1403 (pSaveToItem && pSaveToItem->
GetValue());
1407 if (bOwnTarget && pFilter && !(pFilter->GetFilterFlags() & SfxFilterFlags::STARONEFILTER))
1409 uno::Reference< embed::XStorage > xMedStorage = rMedium.
GetStorage();
1410 if ( !xMedStorage.is() )
1413 pImpl->bForbidReload = bOldStat;
1418 uno::Sequence< beans::NamedValue > aEncryptionData;
1419 bool bPasswdProvided =
false;
1422 bPasswdProvided =
true;
1427 catch( uno::Exception& )
1429 SAL_WARN(
"sfx.doc",
"Setting of common encryption key failed!" );
1438 const SfxStringItem *pVersionItem = !rMedium.
IsInCheckIn()? SfxItemSet::GetItem<SfxStringItem>(pSet, SID_DOCINFO_COMMENTS,
false):
nullptr;
1439 OUString aTmpVersionURL;
1447 OSL_ENSURE( !pVersionItem,
"This scenario is impossible currently!" );
1455 if ( bOk && pVersionItem )
1458 bOk = !aTmpVersionURL.isEmpty();
1464 if ( bOk && officecfg::Office::Common::Save::Document::GenerateThumbnail::get()
1472 SAL_WARN(
"sfx.doc",
"Couldn't store thumbnail representation!" );
1478 if (
pImpl->bIsSaving ||
pImpl->bPreserveVersions )
1482 const Sequence < util::RevisionTag > aVersions = rMedium.
GetVersionList();
1483 if ( aVersions.hasElements() )
1486 static constexpr OUStringLiteral aVersionsName(
u"Versions" );
1487 uno::Reference< embed::XStorage > xNewVerStor = xMedStorage->openStorageElement(
1489 embed::ElementModes::READWRITE );
1490 uno::Reference< embed::XStorage > xOldVerStor =
GetStorage()->openStorageElement(
1492 embed::ElementModes::READ );
1493 if ( !xNewVerStor.is() || !xOldVerStor.is() )
1494 throw uno::RuntimeException();
1496 for (
const auto& rVersion : aVersions )
1498 if ( xOldVerStor->hasByName( rVersion.Identifier ) )
1499 xOldVerStor->copyElementTo( rVersion.Identifier, xNewVerStor, rVersion.Identifier );
1502 uno::Reference< embed::XTransactedObject > xTransact( xNewVerStor, uno::UNO_QUERY );
1503 if ( xTransact.is() )
1504 xTransact->commit();
1507 catch( uno::Exception& )
1509 SAL_WARN(
"sfx.doc",
"Couldn't copy versions!" );
1515 if ( bOk && pVersionItem && !rMedium.
IsInCheckIn() )
1518 const SfxStringItem *pAuthorItem = SfxItemSet::GetItem<SfxStringItem>(pSet, SID_DOCINFO_AUTHOR,
false);
1521 util::RevisionTag aInfo;
1522 aInfo.Comment = pVersionItem->
GetValue();
1526 aInfo.Author = pAuthorItem->
GetValue();
1532 aInfo.TimeStamp.Day = aTime.
GetDay();
1533 aInfo.TimeStamp.Month = aTime.
GetMonth();
1534 aInfo.TimeStamp.Year = aTime.
GetYear();
1535 aInfo.TimeStamp.Hours = aTime.
GetHour();
1536 aInfo.TimeStamp.Minutes = aTime.
GetMin();
1537 aInfo.TimeStamp.Seconds = aTime.
GetSec();
1546 else if ( bOk && (
pImpl->bIsSaving ||
pImpl->bPreserveVersions ) )
1552 if ( !aTmpVersionURL.isEmpty() )
1553 ::utl::UCBContentHelper::Kill( aTmpVersionURL );
1558 if ( rMedium.
GetFilter() && ( rMedium.
GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER ) )
1571 if( bOk && !bCopyTo )
1579 if ( bTryToPreserveScriptSignature && bNoPreserveForOasis )
1582 uno::Reference< security::XDocumentDigitalSignatures > xDDSigns;
1583 if (bTryToPreserveScriptSignature)
1594 uno::Reference < beans::XPropertySet > xPropSet( rMedium.
GetStorage(), uno::UNO_QUERY_THROW );
1595 xPropSet->getPropertyValue(
"Version") >>= aVersion;
1597 catch( uno::Exception& )
1603 const OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName();
1605 if ( !aScriptSignName.isEmpty() )
1613 if ( !xReadOrig.is() )
1614 throw uno::RuntimeException();
1615 uno::Reference< embed::XStorage > xMetaInf = xReadOrig->openStorageElement(
1617 embed::ElementModes::READ );
1621 throw uno::RuntimeException();
1622 uno::Reference< embed::XStorage > xTargetMetaInf =
xTarget->openStorageElement(
1624 embed::ElementModes::READWRITE );
1626 if ( xMetaInf.is() && xTargetMetaInf.is() )
1628 xMetaInf->copyElementTo( aScriptSignName, xTargetMetaInf, aScriptSignName );
1630 uno::Reference< embed::XTransactedObject > xTransact( xTargetMetaInf, uno::UNO_QUERY );
1631 if ( xTransact.is() )
1632 xTransact->commit();
1634 xTargetMetaInf->dispose();
1637 uno::Sequence< security::DocumentSignatureInformation >
aInfos =
1638 xDDSigns->verifyScriptingContentSignatures(
xTarget,
1639 uno::Reference< io::XInputStream >() );
1647 xTransact.set(
xTarget, uno::UNO_QUERY );
1648 if ( xTransact.is() )
1649 xTransact->commit();
1655 SAL_WARN(
"sfx.doc",
"An invalid signature was copied!" );
1660 catch( uno::Exception& )
1669 const OUString sNewName( rMedium.
GetName( ) );
1671 if (
sName != sNewName )
1679 if ( !bCopyTo && bStorageBasedSource && !bStorageBasedTarget )
1681 if ( bStoreToSameLocation )
1685 if ( bNeedsDisconnectionOnFail )
1691 OSL_ENSURE(!
pMedium->
GetName().isEmpty(),
"Fallback is used, the medium without name should not dispose the storage!");
1695 SAL_WARN(
"sfx.doc",
"Process after storing has failed." );
1703 SAL_WARN(
"sfx.doc",
"Storing has failed." );
1706 if ( bNeedsDisconnectionOnFail )
1712 aLockUIGuard.Unlock();
1713 pImpl->bForbidReload = bOldStat;
1720 css::uno::Reference < XPropertySetInfo > xProps = aContent.
getProperties();
1723 static constexpr OUStringLiteral aAuthor(
u"Author" );
1724 static constexpr OUStringLiteral aKeywords(
u"Keywords" );
1725 static constexpr OUStringLiteral aSubject(
u"Subject" );
1727 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1729 uno::Reference<document::XDocumentProperties> xDocProps
1730 = xDPS->getDocumentProperties();
1732 if ( xProps->hasPropertyByName( aAuthor ) )
1736 if ( xProps->hasPropertyByName( aKeywords ) )
1739 aAny <<= ::comphelper::string::convertCommaSeparated(
1740 xDocProps->getKeywords());
1743 if ( xProps->hasPropertyByName( aSubject ) )
1761 uno::Reference< embed::XStorage > xStorage = rSrcMedium.
GetStorage();
1763 bool bResult =
false;
1764 if ( xStorage ==
pImpl->m_xDocStorage )
1768 uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW );
1770 if ( aBackupURL.isEmpty() )
1775 xOptStorage->writeAndAttachToStream( uno::Reference< io::XStream >() );
1787 xOptStorage->attachToURL( aBackupURL,
true );
1794 catch ( uno::Exception& )
1802 const uno::Reference< embed::XStorage >& xStorage,
1813 bool bResult =
false;
1815 if ( xStorage.is() )
1820 uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW );
1821 xOptStorage->writeAndAttachToStream( uno::Reference< io::XStream >() );
1829 catch( uno::Exception& )
1838 DBG_ASSERT( xTmpStorage.is(),
"If a storage can not be created an exception must be thrown!\n" );
1839 if ( !xTmpStorage.is() )
1840 throw uno::RuntimeException();
1844 xStorage->copyToStorage( xTmpStorage );
1849 pImpl->aBasicManager.setStorage( xTmpStorage );
1854 uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries(
pImpl->xBasicLibraries, uno::UNO_QUERY_THROW );
1855 xBasicLibraries->setRootStorage( xTmpStorage );
1857 catch( uno::Exception& )
1861 uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries(
pImpl->xDialogLibraries, uno::UNO_QUERY_THROW );
1862 xDialogLibraries->setRootStorage( xTmpStorage );
1864 catch( uno::Exception& )
1868 catch( uno::Exception& )
1877 else if (!
GetMedium()->GetFilter()->IsOwnFormat())
1890 uno::Reference < embed::XStorage > xNewStor = rMedium.
GetStorage();
1891 if ( !xNewStor.is() )
1894 uno::Reference < beans::XPropertySet > xPropSet( xNewStor, uno::UNO_QUERY );
1895 if ( !xPropSet.is() )
1898 Any a = xPropSet->getPropertyValue(
"MediaType");
1899 OUString aMediaType;
1900 if ( !(
a>>=aMediaType) || aMediaType.isEmpty() )
1902 SAL_WARN(
"sfx.doc",
"The mediatype must be set already!" );
1906 pImpl->bIsSaving =
false;
1912 uno::Reference< embed::XTransactedObject > xTransact( xNewStor, uno::UNO_QUERY_THROW );
1913 xTransact->commit();
1915 catch( uno::Exception& )
1917 SAL_WARN(
"sfx.doc",
"The storage was not committed on DoSaveAs!" );
1935 if (
pImpl->bPreserveVersions )
1948 bool bMedChanged = pNewMed && pNewMed!=
pMedium;
1965 if (!pNewMed->
GetName().isEmpty())
1974 uno::Reference< embed::XStorage > xStorage;
1977 uno::Reference < embed::XStorage > xOld =
GetStorage();
1983 if ( bOk && xStorage.is() && xOld != xStorage
1989 }
catch( uno::Exception& )
2000 if (
pImpl->m_bSavingForSigning && pFilter && pFilter->GetSupportsSigning())
2013 pImpl->aBasicManager.setStorage( xStorage );
2018 uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries(
pImpl->xBasicLibraries, uno::UNO_QUERY_THROW );
2019 xBasicLibraries->setRootStorage( xStorage );
2021 catch( uno::Exception& )
2025 uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries(
pImpl->xDialogLibraries, uno::UNO_QUERY_THROW );
2026 xDialogLibraries->setRootStorage( xStorage );
2028 catch( uno::Exception& )
2048 if ( bOk && pNewMed )
2058 uno::Sequence< beans::PropertyValue > aMediaDescr;
2064 catch( uno::Exception& )
2069 bool bTemplate = pTemplateItem && pTemplateItem->
GetValue();
2102 if (bRegisterRecent)
2116 pOrgFilter ? pOrgFilter->GetMimeType() : OUString(),
2117 pOrgFilter ? pOrgFilter->GetServiceName() : OUString() );
2177 css::uno::Reference<css::text::XTextRange>
const& xInsertPosition)
2179 const OUString aFilterName( rMedium.
GetFilter()->GetFilterName() );
2181 uno::Reference< lang::XMultiServiceFactory > xMan = ::comphelper::getProcessServiceFactory();
2182 uno::Reference < lang::XMultiServiceFactory > xFilterFact (
2183 xMan->createInstance(
"com.sun.star.document.FilterFactory" ), uno::UNO_QUERY );
2185 uno::Sequence < beans::PropertyValue > aProps;
2186 uno::Reference < container::XNameAccess > xFilters ( xFilterFact, uno::UNO_QUERY );
2187 if ( xFilters->hasByName( aFilterName ) )
2189 xFilters->getByName( aFilterName ) >>= aProps;
2193 OUString aFilterImplName;
2194 auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps),
2195 [](
const beans::PropertyValue& rFilterProp) {
return rFilterProp.Name ==
"FilterService"; });
2196 if (pProp != std::cend(aProps))
2197 pProp->Value >>= aFilterImplName;
2199 uno::Reference< document::XFilter > xLoader;
2200 if ( !aFilterImplName.isEmpty() )
2204 xLoader.set( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() ), uno::UNO_QUERY );
2206 catch(
const uno::Exception&)
2216 uno::Reference< lang::XComponent > xComp(
GetModel(), uno::UNO_QUERY_THROW );
2217 uno::Reference< document::XImporter > xImporter( xLoader, uno::UNO_QUERY_THROW );
2218 xImporter->setTargetDocument( xComp );
2220 uno::Sequence < beans::PropertyValue > lDescriptor;
2224 css::uno::Sequence < css::beans::PropertyValue > aArgs ( lDescriptor.getLength() );
2225 css::beans::PropertyValue * pNewValue = aArgs.getArray();
2226 const css::beans::PropertyValue * pOldValue = lDescriptor.getConstArray();
2227 static constexpr OUStringLiteral
sInputStream (
u"InputStream" );
2229 bool bHasInputStream =
false;
2230 bool bHasBaseURL =
false;
2231 sal_Int32 nEnd = lDescriptor.getLength();
2233 for ( sal_Int32
i = 0;
i < nEnd;
i++ )
2235 pNewValue[
i] = pOldValue[
i];
2237 bHasInputStream =
true;
2238 else if ( pOldValue[
i].
Name ==
"DocumentBaseURL" )
2242 if ( !bHasInputStream )
2244 aArgs.realloc ( ++nEnd );
2245 auto pArgs = aArgs.getArray();
2252 aArgs.realloc ( ++nEnd );
2253 auto pArgs = aArgs.getArray();
2254 pArgs[nEnd-1].Name =
"DocumentBaseURL";
2255 pArgs[nEnd-1].Value <<= rMedium.
GetBaseURL();
2258 if (xInsertPosition.is()) {
2259 aArgs.realloc( nEnd += 2 );
2260 auto pArgs = aArgs.getArray();
2261 pArgs[nEnd-2].Name =
"InsertMode";
2262 pArgs[nEnd-2].Value <<=
true;
2263 pArgs[nEnd-1].Name =
"TextInsertModeRange";
2264 pArgs[nEnd-1].Value <<= xInsertPosition;
2269 bool bRtn = xLoader->filter(aArgs);
2271 for (
const auto& rName : aNames )
2274 OSL_ENSURE( xObj.is(),
"An empty entry in the embedded objects list!" );
2277 sal_Int32
nState = xObj->getCurrentState();
2278 if (
nState == embed::EmbedStates::LOADED ||
nState == embed::EmbedStates::RUNNING )
2280 uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
2281 if (xModifiable.is() && xModifiable->isModified())
2283 uno::Reference<embed::XEmbedPersist>
const xPers(xObj, uno::UNO_QUERY);
2284 assert(xPers.is() &&
"Modified object without persistence!");
2287 xModifiable->setModified(
false);
2297 uno::Reference< document::XDocumentPropertiesSupplier > xPropSupplier(
GetModel(), uno::UNO_QUERY_THROW);
2298 uno::Reference<document::XDocumentProperties> xDocProps = xPropSupplier->getDocumentProperties() ;
2299 uno::Reference<beans::XPropertyContainer> xPropertyContainer = xDocProps->getUserDefinedProperties();
2300 if (xPropertyContainer.is())
2302 uno::Reference<beans::XPropertySet> xPropertySet(xPropertyContainer, uno::UNO_QUERY);
2303 if (xPropertySet.is())
2305 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
2306 if (xPropertySetInfo.is() && xPropertySetInfo->hasPropertyByName(
"_MarkAsFinal"))
2308 if (xPropertySet->getPropertyValue(
"_MarkAsFinal").get<
bool>())
2310 uno::Reference< lang::XMultiServiceFactory >
xFactory(
GetModel(), uno::UNO_QUERY);
2311 uno::Reference< beans::XPropertySet > xSettings(
xFactory->createInstance(
"com.sun.star.document.Settings"), uno::UNO_QUERY);
2312 xSettings->setPropertyValue(
"LoadReadonly",
uno::Any(
true));
2314 xPropertyContainer->removeProperty(
"_MarkAsFinal");
2321 catch (
const packages::zip::ZipIOException&)
2325 catch (
const lang::WrappedTargetRuntimeException& rWrapped)
2327 io::WrongFormatException e;
2328 if (rWrapped.TargetException >>= e)
2331 e.Message, DialogMask::ButtonsOk | DialogMask::MessageError ));
2334 catch (
const css::io::IOException& e)
2337 e.Message, DialogMask::ButtonsOk | DialogMask::MessageError ));
2339 catch (
const std::exception& e)
2341 const char *msg = e.what();
2342 const OUString sError(msg, strlen(msg), RTL_TEXTENCODING_ASCII_US);
2343 SAL_WARN(
"sfx.doc",
"exception importing " << sError);
2345 sError, DialogMask::ButtonsOk | DialogMask::MessageError));
2358 const OUString aFilterName( rMedium.
GetFilter()->GetFilterName() );
2359 uno::Reference< document::XExporter > xExporter;
2362 uno::Reference< lang::XMultiServiceFactory > xMan = ::comphelper::getProcessServiceFactory();
2363 uno::Reference < lang::XMultiServiceFactory > xFilterFact (
2364 xMan->createInstance(
"com.sun.star.document.FilterFactory" ), uno::UNO_QUERY );
2366 uno::Sequence < beans::PropertyValue > aProps;
2367 uno::Reference < container::XNameAccess > xFilters ( xFilterFact, uno::UNO_QUERY );
2368 if ( xFilters->hasByName( aFilterName ) )
2369 xFilters->getByName( aFilterName ) >>= aProps;
2371 OUString aFilterImplName;
2372 auto pProp = std::find_if(std::cbegin(aProps), std::cend(aProps),
2373 [](
const beans::PropertyValue& rFilterProp) {
return rFilterProp.Name ==
"FilterService"; });
2374 if (pProp != std::cend(aProps))
2375 pProp->Value >>= aFilterImplName;
2377 if ( !aFilterImplName.isEmpty() )
2381 xExporter.set( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() ), uno::UNO_QUERY );
2383 catch(
const uno::Exception&)
2390 if ( xExporter.is() )
2393 uno::Reference< lang::XComponent > xComp(
GetModel(), uno::UNO_QUERY_THROW );
2394 uno::Reference< document::XFilter > xFilter( xExporter, uno::UNO_QUERY_THROW );
2395 xExporter->setSourceDocument( xComp );
2397 css::uno::Sequence < css::beans::PropertyValue > aOldArgs;
2401 const css::beans::PropertyValue * pOldValue = aOldArgs.getConstArray();
2402 css::uno::Sequence < css::beans::PropertyValue > aArgs ( aOldArgs.getLength() );
2403 css::beans::PropertyValue * pNewValue = aArgs.getArray();
2406 static constexpr OUStringLiteral
sOutputStream (
u"OutputStream" );
2407 static constexpr OUStringLiteral
sStream (
u"StreamForOutput" );
2408 bool bHasOutputStream =
false;
2409 bool bHasStream =
false;
2410 bool bHasBaseURL =
false;
2411 bool bHasFilterName =
false;
2412 bool bIsRedactMode =
false;
2413 bool bIsPreview =
false;
2414 sal_Int32 nEnd = aOldArgs.getLength();
2416 for ( sal_Int32
i = 0;
i < nEnd;
i++ )
2418 pNewValue[
i] = pOldValue[
i];
2419 if ( pOldValue[
i].
Name ==
"FileName" )
2420 pNewValue[
i].Value <<= rMedium.
GetName();
2422 bHasOutputStream =
true;
2425 else if ( pOldValue[
i].
Name ==
"DocumentBaseURL" )
2427 else if( pOldValue[
i].
Name ==
"FilterName" )
2428 bHasFilterName =
true;
2431 const css::uno::Sequence<css::beans::PropertyValue>& rMediumArgs = rMedium.
GetArgs();
2432 for ( sal_Int32
i = 0;
i < rMediumArgs.getLength();
i++ )
2434 if( rMediumArgs[
i].
Name ==
"IsPreview" )
2435 rMediumArgs[
i].Value >>= bIsPreview;
2439 if (rItems.
GetItemState(SID_IS_REDACT_MODE) == SfxItemState::SET)
2440 bIsRedactMode =
true;
2442 if ( !bHasOutputStream )
2444 aArgs.realloc ( ++nEnd );
2445 auto pArgs = aArgs.getArray();
2453 aArgs.realloc ( ++nEnd );
2454 auto pArgs = aArgs.getArray();
2461 aArgs.realloc ( ++nEnd );
2462 auto pArgs = aArgs.getArray();
2463 pArgs[nEnd-1].Name =
"DocumentBaseURL";
2464 pArgs[nEnd-1].Value <<= rMedium.
GetBaseURL(
true );
2467 if( !bHasFilterName )
2469 aArgs.realloc( ++nEnd );
2470 auto pArgs = aArgs.getArray();
2471 pArgs[nEnd-1].Name =
"FilterName";
2472 pArgs[nEnd-1].Value <<= aFilterName;
2477 aArgs.realloc( ++nEnd );
2478 auto pArgs = aArgs.getArray();
2479 pArgs[nEnd-1].Name =
"IsRedactMode";
2480 pArgs[nEnd-1].Value <<= bIsRedactMode;
2485 aArgs.realloc( ++nEnd );
2486 auto pArgs = aArgs.getArray();
2487 pArgs[nEnd-1].Name =
"IsPreview";
2488 pArgs[nEnd-1].Value <<= bIsPreview;
2491 return xFilter->filter( aArgs );
2493 catch (
const css::uno::RuntimeException&)
2498 catch (
const std::exception& e)
2571 std::shared_ptr<const SfxFilter> pFilter = pRetrMedium->
GetFilter();
2575 std::shared_ptr<SfxItemSet> pSet = std::make_shared<SfxAllItemSet>(pRetrMedium->
GetItemSet());
2576 pSet->ClearItem( SID_VERSION );
2577 pSet->ClearItem( SID_DOC_BASEURL );
2584 pSet->Put( *pMajor );
2588 pSet->Put( *pComments );
2609 Any aOriginalInteract;
2610 css::uno::Reference< XInteractionHandler > xInteract;
2611 const SfxUnoAnyItem* pxInteractionItem = SfxItemSet::GetItem<SfxUnoAnyItem>(pArgs, SID_INTERACTIONHANDLER,
false);
2612 if ( pxInteractionItem && ( pxInteractionItem->
GetValue() >>= xInteract ) && xInteract.is() )
2615 aOriginalInteract = pItem->GetValue();
2620 if (pNoFileSync && pNoFileSync->
GetValue())
2623 bool bSaved =
false;
2628 if (aOriginalInteract.hasValue())
2638 DBG_ASSERT(bOpen,
"Error handling for DoSaveCompleted not implemented");
2676 pImpl->bIsSaving =
true;
2677 bool bSaved =
false;
2682 std::shared_ptr<const SfxFilter> pFilter;
2687 pSalvageItem->
GetValue(), StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, pFilter );
2690 if ( pPasswordItem )
2706 const uno::Sequence<beans::PropertyValue>& rArgs)
2708 if(
aURL.HasError() )
2722 if( ( pTmp !=
this ) && pTmp->GetMedium() )
2725 if ( aCompare ==
aURL )
2737 DBG_ASSERT(
aURL.GetProtocol() != INetProtocol::NotValid,
"Illegal URL!" );
2741 bool bSaveTo = pSaveToItem && pSaveToItem->
GetValue();
2745 || !pFilter->CanExport()
2746 || (!bSaveTo && !pFilter->CanImport()) )
2753 const SfxBoolItem* pCopyStreamItem = rItemSet.
GetItem(SID_COPY_STREAM_IF_POSSIBLE,
false);
2759 rItemSet.
ClearItem( SID_COPY_STREAM_IF_POSSIBLE );
2773 if (SfxItemState::SET != rItemSet.
GetItemState(SID_UNPACK) && officecfg::Office::Common::Save::Document::Unpacked::get())
2776#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
2777 OUString aTempFileURL;
2817 if ( pFilterOptItem )
2820#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
2826 if ( pFilter->IsOwnFormat()
2827 && pFilter->UsesStorage()
2838 if ( bWasReadonly && !bSaveTo )
2849 const uno::Sequence<beans::PropertyValue>& rArgs)
2852 std::shared_ptr<SfxAllItemSet> xMergedParams = std::make_shared<SfxAllItemSet>(
pMedium->
GetItemSet() );
2857 if (xMergedParams->HasItem(SID_ENCRYPTIONDATA))
2859 bool bPasswordProtected =
true;
2861 = xMergedParams->GetItem<
SfxUnoAnyItem>(SID_ENCRYPTIONDATA,
false);
2862 if (pEncryptionDataItem)
2864 uno::Sequence<beans::NamedValue> aEncryptionData;
2865 pEncryptionDataItem->
GetValue() >>= aEncryptionData;
2866 for (
const auto& rItem : std::as_const(aEncryptionData))
2868 if (rItem.Name ==
"CryptoType")
2871 rItem.Value >>= aValue;
2872 if (aValue !=
"StrongEncryptionDataSpace")
2875 bPasswordProtected =
false;
2881 if (bPasswordProtected)
2884 xMergedParams->ClearItem(SID_PASSWORD);
2885 xMergedParams->ClearItem(SID_ENCRYPTIONDATA);
2889 xMergedParams->ClearItem( SID_DOCINFO_TITLE );
2891 xMergedParams->ClearItem( SID_INPUTSTREAM );
2892 xMergedParams->ClearItem( SID_STREAM );
2893 xMergedParams->ClearItem( SID_CONTENT );
2894 xMergedParams->ClearItem( SID_DOC_READONLY );
2895 xMergedParams->ClearItem( SID_DOC_BASEURL );
2897 xMergedParams->ClearItem( SID_REPAIRPACKAGE );
2900 xMergedParams->ClearItem( SID_VERSION );
2904 xMergedParams->Put(rItemSet);
2906 SAL_WARN_IF( xMergedParams->GetItemState( SID_DOC_SALVAGE) >= SfxItemState::SET,
2907 "sfx.doc",
"Salvage item present in Itemset, check the parameters!");
2910 xMergedParams->ClearItem( SID_DOC_SALVAGE );
2913 SfxMedium *pNewFile =
new SfxMedium( rFileName, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC,
nullptr, xMergedParams );
2917 if (pNoFileSync && pNoFileSync->
GetValue())
2928 aThumbnailGuard.dismiss();
2931 if ( !aFilterName.isEmpty() )
2933 pNewFile->
SetFilter(
GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) );
2935 if (aFilterName ==
"writer_pdf_Export")
2937 uno::Sequence< beans::PropertyValue > aSaveToFilterDataOptions(2);
2938 auto pSaveToFilterDataOptions = aSaveToFilterDataOptions.getArray();
2941 for(
int i = 0 ;
i< rArgs.getLength() ; ++
i)
2943 auto aProp = rArgs[
i];
2944 if(aProp.Name ==
"EncryptFile")
2946 pSaveToFilterDataOptions[0].Name = aProp.Name;
2947 pSaveToFilterDataOptions[0].Value = aProp.Value;
2950 if(aProp.Name ==
"DocumentOpenPassword")
2952 pSaveToFilterDataOptions[1].Name = aProp.Name;
2953 pSaveToFilterDataOptions[1].Value = aProp.Value;
2963 pNewFile->
SetFilter(
GetFactory().GetFilterContainer()->GetAnyFilter( SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT ) );
2984 pImpl->bIsSaving =
false;
2987 if (
pImpl->bPreserveVersions )
3015 DBG_ASSERT( !bCopyTo,
"Error while reconnecting to medium, can't be handled!");
3022 DBG_ASSERT( bRet,
"Error in DoSaveCompleted, can't be handled!");
3054 SAL_WARN(
"sfx.doc",
"Base implementation, must not be called in general!" );
3077 if (
GetMedium()->GetVersionList().hasElements() )
3094 pResId = STR_HIDDENINFO_CONTINUE_SAVING;
3100 pResId = STR_HIDDENINFO_CONTINUE_PRINTING;
3106 pResId = STR_HIDDENINFO_CONTINUE_SIGNING;
3112 pResId = STR_HIDDENINFO_CONTINUE_CREATEPDF;
3127 bool bWarning =
false;
3149 VclMessageType::Warning, VclButtonsType::YesNo,
sMessage));
3150 xWarn->set_default_response(
RET_NO);
3151 nRet = xWarn->run();
3172 uno::Reference< embed::XStorage > xStorage = rMedium.
GetStorage();
3173 if ( xStorage.is() )
3179 uno::Sequence< beans::NamedValue > aEncryptionData;
3187 catch( uno::Exception& )
3194 return Load( rMedium );
3204 uno::Reference< embed::XStorage > xStorage = rMedium.
GetStorage();
3210 const bool bTemplate = rMedium.
GetFilter()->IsOwnTemplateFormat()
3214#if HAVE_FEATURE_SCRIPTING
3221 pImpl->aBasicManager.storeLibrariesToStorage( xStorage );
3236 bool restoreLanguage =
false;
3237 if (viewLanguage != loadLanguage)
3239 restoreLanguage =
true;
3244 const ::comphelper::ScopeGuard aGuard(
3245 [&viewLanguage, restoreLanguage]()
3255 return SaveAs( rMedium );
3262 if ( !
pImpl->m_xDocStorage.is() )
3264 OSL_ENSURE(
pImpl->m_bCreateTempStor,
"The storage must exist already!" );
3268 OSL_ENSURE(
pImpl->m_xDocStorage.is(),
"The method must either return storage or throw exception!" );
3271 pImpl->m_bCreateTempStor =
false;
3275 catch( uno::Exception& )
3282 OSL_ENSURE(
pImpl->m_xDocStorage.is(),
"The document storage must be created!" );
3283 return pImpl->m_xDocStorage;
3289 if (
pImpl->mxObjectContainer )
3298 uno::Reference < embed::XStorage > xStorage = rMedium.
GetStorage();
3299 if ( !xStorage.is() )
3308 bool AutoSaveEvent =
false;
3312 if (
pImpl->mxObjectContainer )
3318 uno::Sequence<OUString> aExceptions;
3322 if (pNoEmbDS->GetValue())
3323 aExceptions = uno::Sequence<OUString>{
"EmbeddedDatabase" };
3331 bool bResult =
true;
3333 if (
pImpl->mxObjectContainer )
3336 for (
const auto& rName : aNames )
3339 OSL_ENSURE( xObj.is(),
"An empty entry in the embedded objects list!" );
3342 uno::Reference< embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
3343 if ( xPersist.is() )
3347 xPersist->saveCompleted(
false );
3349 catch( uno::Exception& )
3364 bool bForceNonModified )
3366 if ( !xStorage.is() )
3372 if (
pImpl->mxObjectContainer )
3373 pImpl->mxObjectContainer->SetPersistentEntries(xStorage,bForceNonModified);
3381 bool bResult =
false;
3382 bool bSendNotification =
false;
3383 uno::Reference< embed::XStorage > xOldStorageHolder;
3386 bool bHasContainer(
pImpl->mxObjectContainer );
3388 if ( !xStorage.is() || xStorage ==
GetStorage() )
3395 if (
pImpl->mxObjectContainer )
3403 if ( xStorage.is() &&
pImpl->m_xDocStorage != xStorage )
3407 DBG_ASSERT( bHasContainer == (
pImpl->mxObjectContainer !=
nullptr),
"Wrong storage in object container!" );
3408 xOldStorageHolder =
pImpl->m_xDocStorage;
3409 pImpl->m_xDocStorage = xStorage;
3410 bSendNotification =
true;
3418 if (
pImpl->mxObjectContainer )
3425 if ( bSendNotification )
3434 const uno::Reference< embed::XStorage >& xTarget )
3436 OSL_ENSURE( xSource.is() &&
xTarget.is(),
"Source and/or target storages are not available!" );
3442 const uno::Sequence< OUString > aSubElements = xSource->getElementNames();
3443 for (
const auto& rSubElement : aSubElements )
3445 if ( xSource->isStorageElement( rSubElement ) )
3447 OUString aMediaType;
3448 static constexpr OUStringLiteral aMediaTypePropName(
u"MediaType" );
3449 bool bGotMediaType =
false;
3453 uno::Reference< embed::XOptimizedStorage > xOptStorage( xSource, uno::UNO_QUERY_THROW );
3455 ( xOptStorage->getElementPropertyValue( rSubElement, aMediaTypePropName ) >>= aMediaType );
3457 catch( uno::Exception& )
3460 if ( !bGotMediaType )
3462 uno::Reference< embed::XStorage > xSubStorage;
3464 xSubStorage = xSource->openStorageElement( rSubElement, embed::ElementModes::READ );
3465 }
catch( uno::Exception& )
3468 if ( !xSubStorage.is() )
3471 xSource->copyStorageElementLastCommitTo( rSubElement, xSubStorage );
3474 uno::Reference< beans::XPropertySet > xProps( xSubStorage, uno::UNO_QUERY_THROW );
3475 xProps->getPropertyValue( aMediaTypePropName ) >>= aMediaType;
3480 if ( !aMediaType.isEmpty()
3481 && aMediaType !=
"application/vnd.sun.star.oleobject" )
3483 css::datatransfer::DataFlavor aDataFlavor;
3484 aDataFlavor.MimeType = aMediaType;
3489 case SotClipboardFormatId::STARWRITER_60 :
3490 case SotClipboardFormatId::STARWRITERWEB_60 :
3491 case SotClipboardFormatId::STARWRITERGLOB_60 :
3492 case SotClipboardFormatId::STARDRAW_60 :
3493 case SotClipboardFormatId::STARIMPRESS_60 :
3494 case SotClipboardFormatId::STARCALC_60 :
3495 case SotClipboardFormatId::STARCHART_60 :
3496 case SotClipboardFormatId::STARMATH_60 :
3497 case SotClipboardFormatId::STARWRITER_8:
3498 case SotClipboardFormatId::STARWRITERWEB_8:
3499 case SotClipboardFormatId::STARWRITERGLOB_8:
3500 case SotClipboardFormatId::STARDRAW_8:
3501 case SotClipboardFormatId::STARIMPRESS_8:
3502 case SotClipboardFormatId::STARCALC_8:
3503 case SotClipboardFormatId::STARCHART_8:
3504 case SotClipboardFormatId::STARMATH_8:
3509 if ( !
xTarget->hasByName( rSubElement ) )
3517 catch( uno::Exception& )
3519 SAL_WARN(
"sfx.doc",
"Can not check storage consistency!" );
3527 bool bResult =
false;
3529 bool bHasContainer(
pImpl->mxObjectContainer );
3530 if ( xStorage.is() )
3532 if (
pImpl->mxObjectContainer )
3538 "Some of substorages with unknown mimetypes is lost!" );
3544 DBG_ASSERT( bHasContainer == (
pImpl->mxObjectContainer !=
nullptr),
"Wrong storage in object container!" );
3545 if (
pImpl->m_xDocStorage != xStorage )
3556 const uno::Reference< embed::XStorage >& xTarget,
3557 const uno::Sequence<OUString>& rExceptions)
3561 SAL_WARN(
"sfx.doc",
"SfxObjectShell::GetStorage() failed");
3566 bool bResult =
true;
3570 const css::uno::Sequence<OUString> aSubElementNames = xSource->getElementNames();
3571 for (
const OUString& rSubElement : aSubElementNames)
3573 if (std::find(rExceptions.begin(), rExceptions.end(), rSubElement) != rExceptions.end())
3576 if (rSubElement ==
"Configurations")
3579 if (xSource->isStorageElement(rSubElement))
3581 OSL_ENSURE(!
xTarget->hasByName(rSubElement),
"The target storage is an output "
3582 "storage, the element should not "
3583 "exist in the target!");
3585 xSource->copyElementTo(rSubElement,
xTarget, rSubElement);
3588 else if (xSource->isStorageElement(rSubElement))
3590 OUString aMediaType;
3591 static constexpr OUStringLiteral aMediaTypePropName(
u"MediaType" );
3592 bool bGotMediaType =
false;
3596 uno::Reference< embed::XOptimizedStorage > xOptStorage( xSource, uno::UNO_QUERY_THROW );
3597 bGotMediaType = (xOptStorage->getElementPropertyValue(rSubElement, aMediaTypePropName)
3600 catch( uno::Exception& )
3603 if ( !bGotMediaType )
3605 uno::Reference< embed::XStorage > xSubStorage;
3608 = xSource->openStorageElement(rSubElement, embed::ElementModes::READ);
3609 }
catch( uno::Exception& )
3612 if ( !xSubStorage.is() )
3618 xSource->copyStorageElementLastCommitTo(rSubElement, xSubStorage);
3621 uno::Reference< beans::XPropertySet > xProps( xSubStorage, uno::UNO_QUERY_THROW );
3622 xProps->getPropertyValue( aMediaTypePropName ) >>= aMediaType;
3627 if ( !aMediaType.isEmpty()
3628 && aMediaType !=
"application/vnd.sun.star.oleobject" )
3630 css::datatransfer::DataFlavor aDataFlavor;
3631 aDataFlavor.MimeType = aMediaType;
3636 case SotClipboardFormatId::STARWRITER_60 :
3637 case SotClipboardFormatId::STARWRITERWEB_60 :
3638 case SotClipboardFormatId::STARWRITERGLOB_60 :
3639 case SotClipboardFormatId::STARDRAW_60 :
3640 case SotClipboardFormatId::STARIMPRESS_60 :
3641 case SotClipboardFormatId::STARCALC_60 :
3642 case SotClipboardFormatId::STARCHART_60 :
3643 case SotClipboardFormatId::STARMATH_60 :
3644 case SotClipboardFormatId::STARWRITER_8:
3645 case SotClipboardFormatId::STARWRITERWEB_8:
3646 case SotClipboardFormatId::STARWRITERGLOB_8:
3647 case SotClipboardFormatId::STARDRAW_8:
3648 case SotClipboardFormatId::STARIMPRESS_8:
3649 case SotClipboardFormatId::STARCALC_8:
3650 case SotClipboardFormatId::STARCHART_8:
3651 case SotClipboardFormatId::STARMATH_8:
3656 OSL_ENSURE(rSubElement ==
"Configurations2"
3657 || nFormat == SotClipboardFormatId::STARBASE_8
3658 || !
xTarget->hasByName(rSubElement),
3659 "The target storage is an output storage, the element "
3660 "should not exist in the target!");
3662 if (!
xTarget->hasByName(rSubElement))
3664 xSource->copyElementTo(rSubElement,
xTarget, rSubElement);
3672 catch( uno::Exception& )
3686 bool bResult =
false;
3690 uno::Reference<embed::XStorage> xThumbnailStorage = xStorage->openStorageElement(
"Thumbnails", embed::ElementModes::READWRITE);
3692 if (xThumbnailStorage.is())
3694 uno::Reference<io::XStream>
xStream = xThumbnailStorage->openStreamElement(
"thumbnail.png", embed::ElementModes::READWRITE);
3698 uno::Reference<embed::XTransactedObject> xTransactedObject(xThumbnailStorage, uno::UNO_QUERY_THROW);
3699 xTransactedObject->commit();
3704 catch( uno::Exception& )
3716 bool bResult =
false;
3723 uno::Reference<io::XTruncate> xTruncate(
xStream->getOutputStream(), uno::UNO_QUERY_THROW);
3724 xTruncate->truncate();
3726 uno::Reference <beans::XPropertySet> xSet(
xStream, uno::UNO_QUERY);
3728 xSet->setPropertyValue(
"MediaType",
uno::Any(OUString(
"image/png")));
3731 const OUString sResID = GraphicHelper::getThumbnailReplacementIDByFactoryName_Impl(
3733 if (!sResID.isEmpty())
3734 bResult = GraphicHelper::getThumbnailReplacement_Impl(sResID,
xStream);
3741 bResult = GraphicHelper::getThumbnailFormatFromBitmap_Impl(bitmap,
xStream);
3745 catch(uno::Exception&)
3763 uno::Reference<text::XTextRange>
const&)
3772 return pImpl->m_bConfigOptionsChecked;
3777 pImpl->m_bConfigOptionsChecked = bChecked;
3782 pImpl->m_bMacroCallsSeenWhileLoading =
true;
3787 if (officecfg::Office::Common::Security::Scripting::CheckDocumentEvents::get())
3788 return pImpl->m_bMacroCallsSeenWhileLoading;
3794#if !HAVE_FEATURE_SCRIPTING
3800 if ( !
pImpl->aBasicManager.isValid() )
3802 std::vector< OUString > sModules;
3803 if ( xHandler.is() )
3805 if(
pImpl->aBasicManager.ImgVersion12PsswdBinaryLimitExceeded( sModules ) )
3808 xHandler->handle( pReq );
3809 return pReq->isApprove();
3824 if ( officecfg::Office::Common::Security::LoadExoticFileFormats::get() == 0 )
3829 else if ( officecfg::Office::Common::Security::LoadExoticFileFormats::get() == 2 )
3834 else if ( officecfg::Office::Common::Security::LoadExoticFileFormats::get() == 1 && xHandler.is() )
3838 xHandler->handle( xException );
3839 return xException->isApprove();
3847 uno::Reference< task::XInteractionHandler > xRet;
SfxApplication * SfxGetpApp()
ErrCode CheckPasswd_Impl(SfxObjectShell *pDoc, SfxMedium *pFile)
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)
constexpr OUStringLiteral sOutputStream
const sal_uInt16 nVersion
static void AddToRecentDocumentList(const OUString &rFileUrl, const OUString &rMimeType, const OUString &rDocumentService)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
static OUString GetEventName(GlobalEventId nID)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
INetProtocol GetProtocol() const
OUString GetURLNoPass(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SfxFilterMatcher & GetFilterMatcher()
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
void Broadcast(const SfxHint &rHint)
void Lock(bool bLock)
With this method the SfxDispatcher can be locked and released.
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetAnyFilter(SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
std::shared_ptr< const SfxFilter > GetFilter4ClipBoardId(SotClipboardFormatId nId, SfxFilterFlags nMust=SfxFilterFlags::IMPORT, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static const LanguageTag & getLoadLanguage()
Get the language used by the loading view (used for all save operations).
ErrCode const & GetLastStorageCreationState() const
void CreateTempFileNoCopy()
const std::shared_ptr< const SfxFilter > & GetFilter() const
void DisableFileSync(bool bDisableFileSync)
Lets Transfer_Impl() not fsync the output file.
void Close(bool bInDestruction=false)
OUString GetBaseURL(bool bForSaving=false)
SAL_DLLPRIVATE bool TryDirectTransfer(const OUString &aURL, SfxItemSet const &aTargetSet)
void SetHasEmbeddedObjects(bool bHasEmbeddedObjects)
const INetURLObject & GetURLObject() const
css::util::DateTime const & GetInitFileDate(bool bIgnoreOldValue)
SAL_DLLPRIVATE void SetStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xNewStorage)
SfxItemSet & GetItemSet() const
LockFileResult LockOrigFileOnDemand(bool bLoading, bool bNoUI, bool bTryIgnoreLockFile=false, LockFileEntry *pLockData=nullptr)
SAL_DLLPRIVATE SignatureState GetCachedSignatureState_Impl() const
ErrCode GetErrorCode() const
SAL_DLLPRIVATE void CanDisposeStorage_Impl(bool bDisposeStorage)
void SetInCheckIn(bool bInCheckIn)
SAL_DLLPRIVATE void SaveVersionList_Impl()
SAL_DLLPRIVATE void DoBackup_Impl(bool bForceUsingBackupPath)
SAL_DLLPRIVATE OUString const & GetBackup_Impl()
SAL_DLLPRIVATE bool TransferVersionList_Impl(SfxMedium const &rMedium)
StreamMode GetOpenMode() const
const OUString & GetOrigURL() const
SAL_DLLPRIVATE void SetLongName(const OUString &rName)
const css::uno::Sequence< css::util::RevisionTag > & GetVersionList(bool _bNoReload=false)
const OUString & GetName() const
void DisableUnlockWebDAV(bool bDisableUnlockWebDAV=true)
bool SwitchDocumentToFile(const OUString &aURL)
SAL_DLLPRIVATE bool HasStorage_Impl() const
SAL_DLLPRIVATE bool WillDisposeStorageOnClose_Impl()
SAL_DLLPRIVATE void SetCachedSignatureState_Impl(SignatureState nState)
const css::uno::Sequence< css::beans::PropertyValue > & GetArgs() const
SAL_DLLPRIVATE void GetMedium_Impl()
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.
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
SvStream * GetOutStream()
css::uno::Reference< css::io::XInputStream > const & GetInputStream()
SAL_DLLPRIVATE void ClearBackup_Impl()
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()
void SetArgs(const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
SAL_DLLPRIVATE void CloseZipStorage_Impl()
const OUString & GetPhysicalName() const
css::uno::Reference< css::embed::XStorage > GetOutputStorage()
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
SfxFilterContainer * GetFilterContainer() const
const SvGlobalName & GetClassId() const
virtual bool ImportFrom(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
void DoInitUnitTest()
Initialize bare minimum just enough for unit test runs.
virtual bool ConvertFrom(SfxMedium &rMedium)
SAL_DLLPRIVATE bool CommonSaveAs_Impl(const INetURLObject &aURL, const OUString &aFilterName, SfxItemSet &rItemSet, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
void SetError(ErrCode rErr)
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
bool DoSaveAs(SfxMedium &rNewStor)
void SaveChildren(bool bObjectsOnly=false)
void SetConfigOptionsChecked(bool bChecked)
void SetTitle(const OUString &rTitle)
virtual css::uno::Reference< css::task::XInteractionHandler > getInteractionHandler() const override
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
virtual bool LoadFrom(SfxMedium &rMedium)
SAL_DLLPRIVATE bool CanReload_Impl()
ErrCode GetErrorCode() const
SAL_DLLPRIVATE OUString CreateTempCopyOfStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xStorage)
SAL_DLLPRIVATE bool Save_Impl(const SfxItemSet *pSet)
bool IsLoadReadonly() const
bool IsConfigOptionsChecked() const
bool SaveCompletedChildren()
virtual bool Load(SfxMedium &rMedium)
static bool CopyStoragesOfUnknownMediaType(const css::uno::Reference< css::embed::XStorage > &xSource, const css::uno::Reference< css::embed::XStorage > &xTarget, const css::uno::Sequence< OUString > &rExceptions=css::uno::Sequence< OUString >())
static SAL_DLLPRIVATE bool QueryAllowExoticFormat_Impl(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, const OUString &rURL, const OUString &rFilterUIName)
SAL_DLLPRIVATE void SetInitialized_Impl(const bool i_fromInitNew)
bool IsInModalMode() const
bool DoLoadExternal(SfxMedium *pMed)
SAL_DLLPRIVATE bool DisconnectStorage_Impl(SfxMedium &rSrcMedium, SfxMedium &rTargetMedium)
bool IsReadOnlyMedium() const
bool LoadOwnFormat(SfxMedium &pMedium)
SAL_DLLPRIVATE bool DoSave_Impl(const SfxItemSet *pSet)
static bool IsOwnStorageFormat(const SfxMedium &)
BasicManager * GetBasicManager() const
virtual bool SaveAs(SfxMedium &rMedium)
bool IsEnableSetModified() const
SfxObjectCreateMode eCreateMode
bool SaveAsChildren(SfxMedium &rMedium)
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
sal_Int16 QueryHiddenInformation(HiddenWarningFact eFact, weld::Window *pParent)
virtual SfxObjectFactory & GetFactory() const =0
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
bool SwitchToShared(bool bShared, bool bSave)
bool GenerateAndStoreThumbnail(bool bEncrypted, const css::uno::Reference< css::embed::XStorage > &xStor)
virtual bool ConvertTo(SfxMedium &rMedium)
bool IsSecurityOptOpenReadOnly() const
void AddToRecentlyUsedList()
SAL_DLLPRIVATE void FreeSharedFile(const OUString &aTempFileURL)
SAL_DLLPRIVATE bool PutURLContentsToVersionStream_Impl(const OUString &aURL, const css::uno::Reference< css::embed::XStorage > &xDocStorage, const OUString &aStreamName)
bool SwitchChildrenPersistence(const css::uno::Reference< css::embed::XStorage > &xStorage, bool bForceNonModified=false)
void FinishedLoading(SfxLoadedFlags nWhich=SfxLoadedFlags::ALL)
SAL_DLLPRIVATE bool QuerySaveSizeExceededModules_Impl(const css::uno::Reference< css::task::XInteractionHandler > &xHandler)
SAL_DLLPRIVATE bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet *pSet)
virtual bool SaveAsOwnFormat(SfxMedium &pMedium)
virtual bool QuerySlotExecutable(sal_uInt16 nSlotId)
bool WriteThumbnail(bool bEncrypted, const css::uno::Reference< css::io::XStream > &xStream)
SfxMedium * GetMedium() const
void SetReadOnlyUI(bool bReadOnly=true)
css::uno::Reference< css::frame::XModel3 > GetModel() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
SAL_DLLPRIVATE void InitOwnModel_Impl()
bool DoSaveObjectAs(SfxMedium &rNewStor, bool bCommit)
virtual OUString getDocumentBaseURL() const override
void UpdateDocInfoForSave()
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
bool GetMacroCallsSeenWhileLoading() const
SvGlobalName const & GetClassName() const
static SAL_DLLPRIVATE bool IsPackageStorageFormat_Impl(const SfxMedium &)
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
bool SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &xStorage)
css::uno::Reference< css::embed::XStorage > const & GetStorage()
BitmapEx GetPreviewBitmap() const
void SetupStorage(const css::uno::Reference< css::embed::XStorage > &xStorage, sal_Int32 nVersion, bool bTemplate) const
void EnableSetModified(bool bEnable=true)
void SetUseThumbnailSave(bool _bNew)
bool IsUseThumbnailSave() const
virtual bool LoadExternal(SfxMedium &rMedium)
bool DoLoad(SfxMedium *pMedium)
void SetLoadReadonly(bool _bReadonly)
bool ExportTo(SfxMedium &rMedium)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
SfxObjectCreateMode GetCreateMode() const
SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl()
void SetMacroCallsSeenWhileLoading()
SAL_DLLPRIVATE bool ImportFromGeneratedStream_Impl(const css::uno::Reference< css::io::XStream > &xStream, const css::uno::Sequence< css::beans::PropertyValue > &aMediaDescr)
static void ReconnectDdeLinks(SfxObjectShell &rServer)
virtual void UpdateLinks()
SAL_DLLPRIVATE bool PreDoSaveAs_Impl(const OUString &rFileName, const OUString &rFiltName, SfxItemSet const &rItemSet, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)
SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId)
bool bIsInGenerateThumbnail
virtual void TerminateEditing()
Terminate any in-flight editing. Used before saving, primarily by Calc to commit cell changes.
SAL_DLLPRIVATE bool ConnectTmpStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xStorage, SfxMedium *pMedium)
static ErrCode HandleFilter(SfxMedium *pMedium, SfxObjectShell const *pDoc)
virtual bool InsertGeneratedStream(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
a very special case to insert at a position in Writer from UNO, via OwnSubFilterService
SAL_DLLPRIVATE bool GeneralInit_Impl(const css::uno::Reference< css::embed::XStorage > &xStorage, bool bTypeMustBeSetAlready)
virtual void SetModified(bool bModified=true)
void SetSecurityOptOpenReadOnly(bool bOpenReadOnly)
SfxItemPool & GetPool() const
Each Subclass of SfxShell must reference a pool.
void SetName(const OUString &rName)
Sets the name of the Shell object.
const css::uno::Any & GetValue() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxDispatcher * GetDispatcher()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void Enable(bool bEnable)
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
static SotClipboardFormatId GetFormat(const css::datatransfer::DataFlavor &rFlavor)
sal_Int32 GetVersion() const
static sal_uInt32 GetLanguageEntryCount()
bool StoreAsChildren(bool _bOasisFormat, bool _bCreateEmbedded, bool _bAutoSaveEvent, const css::uno::Reference< css::embed::XStorage > &_xStorage)
bool StoreChildren(bool _bOasisFormat, bool _bObjectsOnly)
void SwitchPersistence(const css::uno::Reference< css::embed::XStorage > &)
css::uno::Sequence< OUString > GetObjectNames() const
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
static css::uno::Reference< css::embed::XStorage > GetStorageFromStream(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 >())
static css::uno::Sequence< css::beans::NamedValue > CreatePackageEncryptionData(std::u16string_view aPassword)
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 void CopyInputToOutput(const css::uno::Reference< css::io::XInputStream > &xInput, const css::uno::Reference< css::io::XOutputStream > &xOutput)
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static css::uno::Reference< css::io::XInputStream > GetInputStreamFromURL(const OUString &aURL, const css::uno::Reference< css::uno::XComponentContext > &context)
css::uno::Any setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue)
css::uno::Any getPropertyValue(const OUString &rPropertyName)
css::uno::Reference< css::beans::XPropertySetInfo > getProperties()
static OUString GetGeneratorString()
#define DBG_ASSERT(sCon, aError)
OString exceptionToString(const css::uno::Any &caught)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
constexpr OUStringLiteral ODFVER_013_TEXT
constexpr OUStringLiteral ODFVER_012_TEXT
#define ERRCODE_IO_FILTERDISABLED
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_BROKENPACKAGE
#define ERRCODE_IO_INVALIDPARAMETER
Reference< XInterface > xTarget
Reference< XSingleServiceFactory > xFactory
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
std::unique_ptr< sal_Int32[]> pData
SignatureState getSignatureState(const uno::Sequence< security::DocumentSignatureInformation > &aSigInfo)
bool isTrustedLocationUri(OUString const &uri)
bool IsOptionSet(EOption eOption)
const LanguageTag & getLanguageTag()
void setLanguageTag(const LanguageTag &languageTag)
Reference< XComponentContext > getProcessComponentContext()
Any SAL_CALL getCaughtException()
UNOTOOLS_DLLPUBLIC css::uno::Reference< css::ucb::XCommandEnvironment > getDefaultCommandEnvironment()
static OUString lcl_strip_template(const OUString &aString)
void impl_addToModelCollection(const css::uno::Reference< css::frame::XModel > &xModel)
bool GetEncryptionData_Impl(const SfxItemSet *pSet, uno::Sequence< beans::NamedValue > &o_rEncryptionData)
static bool StoragesOfUnknownMediaTypeAreCopied_Impl(const uno::Reference< embed::XStorage > &xSource, const uno::Reference< embed::XStorage > &xTarget)
Sequence< Property > aInfos
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
#define ERRCODE_SFX_FORMAT_ROWCOL
#define ERRCODE_SFX_ALREADYOPEN
#define ERRCODE_SFX_DOLOADFAILED
#define ERRCODE_SFX_DOCUMENTREADONLY
OUString SfxResId(TranslateId aId)
Reference< XModel > xModel