This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch odf-devel
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 9d3da345bbb9c044d2efe5451a4355edad95d458
Author: Jim Jagielski <[email protected]>
AuthorDate: Tue Oct 27 11:43:23 2026 -0400

    embeddedobj: re-export embedded documents instead of copying them in ODF 
1.2 strict mode
---
 .../source/commonembedding/persistence.cxx         | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/main/embeddedobj/source/commonembedding/persistence.cxx 
b/main/embeddedobj/source/commonembedding/persistence.cxx
index 8245a81de3..717133e273 100644
--- a/main/embeddedobj/source/commonembedding/persistence.cxx
+++ b/main/embeddedobj/source/commonembedding/persistence.cxx
@@ -53,6 +53,7 @@
 #include <com/sun/star/beans/IllegalTypeException.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 
+#include <comphelper/configurationhelper.hxx>
 #include <comphelper/fileformat.h>
 #include <comphelper/storagehelper.hxx>
 #include <comphelper/mimeconfighelper.hxx>
@@ -67,6 +68,28 @@
 using namespace ::com::sun::star;
 
 
+//------------------------------------------------------
+// the value of Save/ODF/DefaultVersion that selects strict ODF 1.2 
(SvtSaveOptions::ODFVER_012)
+static sal_Bool IsStrictODF12_Impl( const uno::Reference< 
lang::XMultiServiceFactory >& xFactory )
+{
+       try
+       {
+               sal_Int16 nVersion = 0;
+               ::comphelper::ConfigurationHelper::readDirectKey(
+                               xFactory,
+                               ::rtl::OUString::createFromAscii( 
"org.openoffice.Office.Common/" ),
+                               ::rtl::OUString::createFromAscii( "Save/ODF" ),
+                               ::rtl::OUString::createFromAscii( 
"DefaultVersion" ),
+                               ::comphelper::ConfigurationHelper::E_READONLY ) 
>>= nVersion;
+               return nVersion == 4;
+       }
+       catch ( uno::Exception& )
+       {
+       }
+
+       return sal_False;
+}
+
 //------------------------------------------------------
 uno::Sequence< beans::PropertyValue > GetValuableArgs_Impl( const 
uno::Sequence< beans::PropertyValue >& aMedDescr,
                                                                                
                                        sal_Bool bCanUseDocumentBaseURL )
@@ -1218,6 +1241,20 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const 
uno::Reference< embed::
 
        sal_Bool bSwitchBackToLoaded = sal_False;
 
+       // strict ODF 1.2: write the object anew instead of copying a stream 
that may not be strict;
+       // if the object can not be started the stream is copied as before
+       if ( m_nObjectState == embed::EmbedStates::LOADED && 
IsStrictODF12_Impl( m_xFactory ) )
+       {
+               try
+               {
+                       changeState( embed::EmbedStates::RUNNING );
+                       bSwitchBackToLoaded = sal_True;
+               }
+               catch ( uno::Exception& )
+               {
+               }
+       }
+
        // Storing to different format can be done only in running state.
        if ( m_nObjectState == embed::EmbedStates::LOADED )
        {
@@ -1346,6 +1383,20 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const 
uno::Reference< embed::
 
        sal_Bool bSwitchBackToLoaded = sal_False;
 
+       // strict ODF 1.2: write the object anew instead of copying a stream 
that may not be strict;
+       // if the object can not be started the stream is copied as before
+       if ( m_nObjectState == embed::EmbedStates::LOADED && 
IsStrictODF12_Impl( m_xFactory ) )
+       {
+               try
+               {
+                       changeState( embed::EmbedStates::RUNNING );
+                       bSwitchBackToLoaded = sal_True;
+               }
+               catch ( uno::Exception& )
+               {
+               }
+       }
+
        // Storing to different format can be done only in running state.
        if ( m_nObjectState == embed::EmbedStates::LOADED )
        {

Reply via email to