[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 5 commits - embeddedobj/source sw/qa sw/source vcl/headless
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 9 21:33:28 UTC 2021
embeddedobj/source/commonembedding/embedobj.cxx | 8 +
embeddedobj/source/commonembedding/miscobj.cxx | 68 +++++++++++++
embeddedobj/source/commonembedding/persistence.cxx | 93 ++++++++++++++-----
embeddedobj/source/commonembedding/visobj.cxx | 8 -
embeddedobj/source/inc/commonembobj.hxx | 7 +
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 -
sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc |binary
sw/qa/extras/ww8export/ww8export3.cxx | 6 +
sw/qa/extras/ww8import/ww8import.cxx | 4
sw/source/filter/ww8/docxattributeoutput.cxx | 8 -
sw/source/filter/ww8/ww8par6.cxx | 6 -
vcl/headless/svpgdi.cxx | 5 -
12 files changed, 179 insertions(+), 42 deletions(-)
New commits:
commit 855d02e3221c5f84b0c36fd80d40d164ff75a9a8
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Apr 9 13:58:28 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Apr 9 23:32:42 2021 +0200
fix small cairo leak in gen backend
Change-Id: I57b8cd00d252cef2699d499b9080f829be9098da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113854
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 40e2ad1542b1..0b62ccf467c1 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1982,6 +1982,7 @@ bool SvpSalGraphics::drawGradient(const tools::PolyPolygon& rPolyPolygon, const
1.0);
cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
basegfx::B2DRange extents = getClippedFillDamage(cr);
cairo_fill_preserve(cr);
@@ -2001,8 +2002,7 @@ bool SvpSalGraphics::implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolyg
for (auto const & rPolygon : rPolyPolygon)
AddPolygonToPath(cr, rPolygon, rObjectToDevice, !getAntiAlias(), false);
- cairo_pattern_t* pattern;
- pattern = cairo_pattern_create_linear(rGradient.maPoint1.getX(), rGradient.maPoint1.getY(), rGradient.maPoint2.getX(), rGradient.maPoint2.getY());
+ cairo_pattern_t* pattern = cairo_pattern_create_linear(rGradient.maPoint1.getX(), rGradient.maPoint1.getY(), rGradient.maPoint2.getX(), rGradient.maPoint2.getY());
for (SalGradientStop const & rStop : rGradient.maStops)
{
@@ -2015,6 +2015,7 @@ bool SvpSalGraphics::implDrawGradient(basegfx::B2DPolyPolygon const & rPolyPolyg
cairo_pattern_add_color_stop_rgba(pattern, offset, r, g, b, a);
}
cairo_set_source(cr, pattern);
+ cairo_pattern_destroy(pattern);
basegfx::B2DRange extents = getClippedFillDamage(cr);
cairo_fill_preserve(cr);
commit 9123ddef8950f5b069b738e9e0203dc78d3e772c
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Thu Apr 8 20:27:58 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Apr 9 23:32:37 2021 +0200
tdf#97569 docxexport: export russianUpper/russianLower numbering
Change-Id: Iad5f5d4687eccc05a63d6a9a4f81cf3f552cb17d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113829
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
(cherry picked from commit 3236020c4b8bed68dcf57210c0437f43f4160130)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113771
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 26151ebcc0c9..2044d76b82e7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -760,10 +760,10 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOOxmlOutlineNumberTypes, "outline-number
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[2]/w:numFmt", "val", "decimal");
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[3]/w:numFmt", "val", "decimal");
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[4]/w:numFmt", "val", "decimal");
- assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[5]/w:numFmt", "val", "decimal");
- assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[6]/w:numFmt", "val", "decimal");
- assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[7]/w:numFmt", "val", "decimal");
- assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[8]/w:numFmt", "val", "decimal");
+ assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[5]/w:numFmt", "val", "russianUpper");
+ assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[6]/w:numFmt", "val", "russianLower");
+ assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[7]/w:numFmt", "val", "russianUpper");
+ assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[2]/w:lvl[8]/w:numFmt", "val", "russianLower");
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[3]/w:lvl[1]/w:numFmt", "val", "decimal");
assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[3]/w:lvl[2]/w:numFmt", "val", "decimal");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a33d0d9681dc..318c40dd9248 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6827,6 +6827,10 @@ static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSe
case style::NumberingType::CHARS_ARABIC: aType="arabicAlpha"; break;
case style::NumberingType::CHARS_THAI: aType="thaiLetters"; break;
case style::NumberingType::CHARS_PERSIAN: aType="hindiVowels"; break;
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU:
+ case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU: aType = "russianUpper"; break;
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU:
+ case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU: aType = "russianLower"; break;
case style::NumberingType::TEXT_NUMBER: aType="ordinal"; break;
case style::NumberingType::TEXT_CARDINAL: aType="cardinalText"; break;
case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"; break;
@@ -6861,10 +6865,6 @@ static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSe
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_BG:
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_BG:
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_BG:
- case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_RU:
- case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_N_RU:
- case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_N_RU:
case style::NumberingType::CHARS_MYANMAR:
case style::NumberingType::CHARS_CYRILLIC_UPPER_LETTER_SR:
case style::NumberingType::CHARS_CYRILLIC_LOWER_LETTER_SR:
commit 53380332b64bcce304d32906c5933a370497ea84
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Tue Apr 6 16:40:25 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Apr 9 23:32:32 2021 +0200
tdf#139495 doc import: prevent negative Int forced into uInt
Don't cast a negative number into a sal_uInt16
and expect good results. (ww8import test)
But for bug 139495 (and ww8export3), the problem area is also
related to pHdFormat->SetFormatAttr(SwFormatFrameSize...
which takes an awt::Size which consists of Longs.
So they should accept negative numbers.
Likely the result is being treated as a uInt somewhere.
And a negative height doesn't mean very much anyway.
There seems to be a fundamental difference between
Word and LO here. Word sets the page margins,
but that is irrelevant to the header/footer,
which have their own distance from the edge.
In LO, the header starts at the page margin,
and the body text must follow the header,
(In Word, the body text can start above the header,
as seen in the ww8export3 unit test.)
[FYI: DOC format (since forever) seems to ignore the header size,
allowing the content to at least overlap with the body text,
but DOCX doesn't have that.
Likely this is #112727# using floating frames hack.
So I'd better not keep messing around in here.]
Change-Id: Ie7bffec8a3de25958cf1f311ff2c8338d4870d99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113681
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth at sil.org>
(cherry picked from commit 28a9a92105f3155d82fd9e31095efabd3ec706ea)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113769
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc b/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc
new file mode 100644
index 000000000000..c45a6c25fd99
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf139495_tinyHeader.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export3.cxx b/sw/qa/extras/ww8export/ww8export3.cxx
index b2f67fdd028c..2da94717f407 100644
--- a/sw/qa/extras/ww8export/ww8export3.cxx
+++ b/sw/qa/extras/ww8export/ww8export3.cxx
@@ -229,6 +229,12 @@ DECLARE_WW8EXPORT_TEST(testTdf122460_header, "tdf122460_header.odt")
CPPUNIT_ASSERT(headerIsOn);
}
+DECLARE_WW8EXPORT_TEST(testTdf139495_tinyHeader, "tdf139495_tinyHeader.doc")
+{
+ // In Word 2003, this is one page, but definitely not six pages.
+ CPPUNIT_ASSERT(getPages() < 3);
+}
+
DECLARE_WW8EXPORT_TEST(testFdo53985, "fdo53985.doc")
{
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 9cbae7f83a3a..0698c9578fa8 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -246,6 +246,10 @@ DECLARE_WW8IMPORT_TEST(testTdf122425_1, "tdf122425_1.doc")
CPPUNIT_ASSERT(!pBox->GetLine(eLine));
}
}
+
+ //tdf#139495: without the fix, a negative number was converted into a uInt16, overflowing to 115501
+ auto nDist = getProperty<sal_uInt32>(getStyles("PageStyles")->getByName("Standard"), "HeaderBodyDistance");
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), nDist);
}
DECLARE_WW8IMPORT_TEST(testTdf110987, "tdf110987")
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index a315beb83009..00859aac5221 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -664,8 +664,10 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat,
}
else
{
+ // Hack alert: these calculations are based on
+ // #112727# import negative height headers/footers as floating frames inside fixed height headers/footer
// #i48832# - set correct spacing between header and body.
- const sal_Int32 nHdLowerSpace( std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo );
+ const sal_Int32 nHdLowerSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaTop) - rData.nSwUp - rData.nSwHLo));
pHdFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwHLo + nHdLowerSpace));
aHdUL.SetLower( static_cast< sal_uInt16 >(nHdLowerSpace) );
pHdFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem(
@@ -692,7 +694,7 @@ void wwSectionManager::SetPageULSpaceItems(SwFrameFormat &rFormat,
else
{
// #i48832# - set correct spacing between footer and body.
- const SwTwips nFtUpperSpace( std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp );
+ const sal_Int32 nFtUpperSpace(std::max<sal_Int32>(0, std::abs(rSection.maSep.dyaBottom) - rData.nSwLo - rData.nSwFUp));
pFtFormat->SetFormatAttr(SwFormatFrameSize(SwFrameSize::Fixed, 0, rData.nSwFUp + nFtUpperSpace));
aFtUL.SetUpper( static_cast< sal_uInt16 >(nFtUpperSpace) );
pFtFormat->SetFormatAttr(SwHeaderAndFooterEatSpacingItem(
commit 94afd81f9b42e303c7e2fe3e5e912cc8a769e43c
Author: Armin Le Grand (Allotropia) <armin.le.grand at me.com>
AuthorDate: Thu Apr 8 10:30:15 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Apr 9 23:32:26 2021 +0200
tdf#141529 sync linked OLE save(s) with hosting file save(s)
Before deactivating a linked OLE saved it and overwrote the
original, even when not saving the hosting document at all.
This is not intuitive from user perspective and may lead
to unexpected data loss (of the OLE content).
Reported case was especially about closing the hosted document
without saving in the understandable believe that that way the
changed OLE will not be changed on external medium.
Added mechanism for linked OLE to hold data in a hidden local
temp file, synching/writing back on hosting file save. Most
complicated was adapting the 'break link' case and ensuring
other cases to work, but looks good now from my POV
Change-Id: I7f63d667820b2d9725abc598a9dd7360be1f8d5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113793
Tested-by: Armin Le Grand <Armin.Le.Grand at me.com>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
(cherry picked from commit f4c66a2272d890eaa7a6d7429e5bfa7bdb1f7162)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113762
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx
index 669ba884b055..ffa2a0789be0 100644
--- a/embeddedobj/source/commonembedding/embedobj.cxx
+++ b/embeddedobj/source/commonembedding/embedobj.cxx
@@ -100,6 +100,12 @@ void OCommonEmbeddedObject::Deactivate()
{
try {
xClientSite->saveObject();
+
+ // tdf#141529 take note that an eventually used linked file
+ // got changed/saved/written and that we need to copy it back if the
+ // hosting file/document gets saved
+ if(m_aLinkTempFile.is())
+ m_bLinkTempFileChanged = true;
}
catch( const embed::ObjectSaveVetoException& )
{
@@ -168,7 +174,7 @@ void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
// after the object reaches the running state the cloned size is not necessary any more
m_bHasClonedSize = false;
- if ( m_bIsLink )
+ if ( m_bIsLinkURL )
{
m_xDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
}
diff --git a/embeddedobj/source/commonembedding/miscobj.cxx b/embeddedobj/source/commonembedding/miscobj.cxx
index c62527f84398..7b821affa7f5 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -27,6 +27,10 @@
#include <com/sun/star/lang/NoSupportException.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <com/sun/star/io/TempFile.hpp>
+#include <comphelper/storagehelper.hxx>
+
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/mimeconfighelper.hxx>
@@ -53,8 +57,10 @@ OCommonEmbeddedObject::OCommonEmbeddedObject( const uno::Reference< uno::XCompon
, m_bEmbeddedScriptSupport( true )
, m_bDocumentRecoverySupport( true )
, m_bWaitSaveCompleted( false )
-, m_bIsLink( false )
+, m_bIsLinkURL( false )
+, m_bLinkTempFileChanged( false )
, m_bLinkHasPassword( false )
+, m_aLinkTempFile( )
, m_bHasClonedSize( false )
, m_nClonedMapUnit( 0 )
{
@@ -79,8 +85,10 @@ OCommonEmbeddedObject::OCommonEmbeddedObject(
, m_bEmbeddedScriptSupport( true )
, m_bDocumentRecoverySupport( true )
, m_bWaitSaveCompleted( false )
-, m_bIsLink( true )
+, m_bIsLinkURL( true )
+, m_bLinkTempFileChanged( false )
, m_bLinkHasPassword( false )
+, m_aLinkTempFile( )
, m_bHasClonedSize( false )
, m_nClonedMapUnit( 0 )
{
@@ -215,7 +223,61 @@ void OCommonEmbeddedObject::LinkInit_Impl(
m_bReadOnly = aExportFilterName != m_aLinkFilterName;
}
- m_aDocMediaDescriptor = GetValuableArgs_Impl( aMediaDescr, false );
+ if(m_bIsLinkURL && !m_bReadOnly)
+ {
+ // tdf#141529 we have a linked OLE object. To prevent the original OLE
+ // data to be changed each time the OLE gets changed (at deactivate), copy it to
+ // a temporary file. That file will be changed on activated OLE changes then.
+ // The moment the original gets changed itself will now be associated with the
+ // file/document embedding the OLE being changed (see other additions to the
+ // task-ID above)
+ //
+ // open OLE original data as read input file
+ uno::Reference< ucb::XSimpleFileAccess3 > xTempAccess( ucb::SimpleFileAccess::create( m_xContext ) );
+ uno::Reference< io::XInputStream > xInStream( xTempAccess->openFileRead( m_aLinkURL ) );
+
+ if(xInStream.is())
+ {
+ // create temporary file
+ m_aLinkTempFile = io::TempFile::create(m_xContext);
+
+ if(m_aLinkTempFile.is())
+ {
+ // completely copy content of original OLE data
+ uno::Reference < io::XOutputStream > xTempOut = m_aLinkTempFile->getOutputStream();
+ ::comphelper::OStorageHelper::CopyInputToOutput( xInStream, xTempOut );
+ xTempOut->flush();
+ xTempOut->closeOutput();
+
+ // reset flag m_bLinkTempFileChanged, so it will also work for multiple
+ // save op's of the containing file/document
+ m_bLinkTempFileChanged = false;
+ }
+ }
+ }
+
+ if(m_aLinkTempFile.is())
+ {
+ uno::Sequence< beans::PropertyValue > aAlternativeMediaDescr(aMediaDescr.getLength());
+
+ for ( sal_Int32 a(0); a < aMediaDescr.getLength(); a++ )
+ {
+ const beans::PropertyValue& rSource(aMediaDescr[a]);
+ beans::PropertyValue& rDestination(aAlternativeMediaDescr[a]);
+
+ rDestination.Name = rSource.Name;
+ if(rSource.Name == "URL")
+ rDestination.Value <<= m_aLinkTempFile->getUri();
+ else
+ rDestination.Value = rSource.Value;
+ }
+
+ m_aDocMediaDescriptor = GetValuableArgs_Impl( aAlternativeMediaDescr, false );
+ }
+ else
+ {
+ m_aDocMediaDescriptor = GetValuableArgs_Impl( aMediaDescr, false );
+ }
uno::Reference< frame::XDispatchProviderInterceptor > xDispatchInterceptor;
for ( beans::PropertyValue const & prop : aObjectDescr )
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index bf0bcdf2bbf2..d21eb297360a 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -47,6 +47,9 @@
#include <com/sun/star/beans/IllegalTypeException.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <com/sun/star/io/XTruncate.hpp>
+
#include <comphelper/fileformat.h>
#include <comphelper/storagehelper.hxx>
#include <comphelper/mimeconfighelper.hxx>
@@ -254,7 +257,7 @@ void OCommonEmbeddedObject::SwitchOwnPersistence( const uno::Reference< embed::X
m_aEntryName = aNewName;
// the linked document should not be switched
- if ( !m_bIsLink )
+ if ( !m_bIsLinkURL )
{
uno::Reference< document::XStorageBasedDocument > xDoc( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
if ( xDoc.is() )
@@ -369,10 +372,16 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadLink_Impl()
sal_Int32 nLen = 2;
uno::Sequence< beans::PropertyValue > aArgs( nLen );
+
aArgs[0].Name = "URL";
- aArgs[0].Value <<= m_aLinkURL;
+ if(m_aLinkTempFile.is())
+ aArgs[0].Value <<= m_aLinkTempFile->getUri();
+ else
+ aArgs[0].Value <<= m_aLinkURL;
+
aArgs[1].Name = "FilterName";
aArgs[1].Value <<= m_aLinkFilterName;
+
if ( m_bLinkHasPassword )
{
aArgs.realloc( ++nLen );
@@ -843,7 +852,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::CreateTempDocFromLink_
{
uno::Reference< util::XCloseable > xResult;
- SAL_WARN_IF( !m_bIsLink, "embeddedobj.common", "The object is not a linked one!" );
+ SAL_WARN_IF( !m_bIsLinkURL, "embeddedobj.common", "The object is not a linked one!" );
uno::Sequence< beans::PropertyValue > aTempMediaDescr;
@@ -895,7 +904,12 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::CreateTempDocFromLink_
{
aTempMediaDescr.realloc( 2 );
aTempMediaDescr[0].Name = "URL";
- aTempMediaDescr[0].Value <<= m_aLinkURL;
+
+ // tdf#141529 use URL of the linked TempFile if it exists
+ aTempMediaDescr[0].Value <<= m_aLinkTempFile.is()
+ ? m_aLinkTempFile->getUri()
+ : m_aLinkURL;
+
aTempMediaDescr[1].Name = "FilterName";
aTempMediaDescr[1].Value <<= m_aLinkFilterName;
}
@@ -968,8 +982,8 @@ void SAL_CALL OCommonEmbeddedObject::setPersistentEntry(
// for now support of this interface is required to allow breaking of links and converting them to normal embedded
// objects, so the persist name must be handled correctly ( althowgh no real persist entry is used )
- // OSL_ENSURE( !m_bIsLink, "This method implementation must not be used for links!" );
- if ( m_bIsLink )
+ // OSL_ENSURE( !m_bIsLinkURL, "This method implementation must not be used for links!" );
+ if ( m_bIsLinkURL )
{
m_aEntryName = sEntName;
return;
@@ -1147,8 +1161,8 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed::
// for now support of this interface is required to allow breaking of links and converting them to normal embedded
// objects, so the persist name must be handled correctly ( althowgh no real persist entry is used )
- // OSL_ENSURE( !m_bIsLink, "This method implementation must not be used for links!" );
- if ( m_bIsLink )
+ // OSL_ENSURE( !m_bIsLinkURL, "This method implementation must not be used for links!" );
+ if ( m_bIsLinkURL )
return;
OSL_ENSURE( m_xParentStorage.is() && m_xObjectStorage.is(), "The object has no valid persistence!" );
@@ -1275,10 +1289,33 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed::
// for now support of this interface is required to allow breaking of links and converting them to normal embedded
// objects, so the persist name must be handled correctly ( althowgh no real persist entry is used )
- // OSL_ENSURE( !m_bIsLink, "This method implementation must not be used for links!" );
- if ( m_bIsLink )
+ // OSL_ENSURE( !m_bIsLinkURL, "This method implementation must not be used for links!" );
+ if ( m_bIsLinkURL )
{
m_aNewEntryName = sEntName;
+
+ if(m_aLinkTempFile.is() && m_bLinkTempFileChanged)
+ {
+ // tdf#141529 if we have a changed copy of the original OLE data we now
+ // need to write it back 'over' the original OLE data
+ uno::Reference < ucb::XSimpleFileAccess2 > xFileAccess(ucb::SimpleFileAccess::create( m_xContext ));
+ uno::Reference < io::XInputStream > xTempIn = m_aLinkTempFile->getInputStream();
+
+ // This is *needed* since OTempFileService calls OTempFileService::readBytes which
+ // ensures the SvStream mpStream gets/is opened, *but* also sets the mnCachedPos from
+ // OTempFileService which still points to the end-of-file (from write-cc'ing).
+ uno::Reference < io::XSeekable > xSeek( xTempIn, uno::UNO_QUERY_THROW );
+ xSeek->seek(0);
+
+ xFileAccess->writeFile(m_aLinkURL, xTempIn);
+
+ // Do *not* close input, that would remove the temporary file too early
+ // xTempIn->closeInput();
+
+ // reset flag m_bLinkTempFileChanged
+ m_bLinkTempFileChanged = false;
+ }
+
return;
}
@@ -1407,8 +1444,8 @@ void SAL_CALL OCommonEmbeddedObject::saveCompleted( sal_Bool bUseNew )
// for now support of this interface is required to allow breaking of links and converting them to normal embedded
// objects, so the persist name must be handled correctly ( althowgh no real persist entry is used )
- // OSL_ENSURE( !m_bIsLink, "This method implementation must not be used for links!" );
- if ( m_bIsLink )
+ // OSL_ENSURE( !m_bIsLinkURL, "This method implementation must not be used for links!" );
+ if ( m_bIsLinkURL )
{
if ( bUseNew )
m_aEntryName = m_aNewEntryName;
@@ -1542,7 +1579,7 @@ void SAL_CALL OCommonEmbeddedObject::storeOwn()
if ( !m_xDocHolder->GetComponent().is() )
throw uno::RuntimeException();
- if ( m_bIsLink )
+ if ( m_bIsLinkURL )
{
// TODO: just store the document to its location
uno::Reference< frame::XStorable > xStorable( m_xDocHolder->GetComponent(), uno::UNO_QUERY_THROW );
@@ -1650,7 +1687,7 @@ void SAL_CALL OCommonEmbeddedObject::reload(
"The object waits for saveCompleted() call!",
static_cast< ::cppu::OWeakObject* >(this) );
- if ( m_bIsLink )
+ if ( m_bIsLinkURL )
{
// reload of the link
OUString aOldLinkFilter = m_aLinkFilterName;
@@ -1719,7 +1756,7 @@ void SAL_CALL OCommonEmbeddedObject::reload(
if ( prop.Name == "ReadOnly" )
prop.Value >>= m_bReadOnly;
- if ( bOldReadOnlyValue == m_bReadOnly || m_bIsLink )
+ if ( bOldReadOnlyValue == m_bReadOnly || m_bIsLinkURL )
return;
// close own storage
@@ -1751,7 +1788,7 @@ void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XSt
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
- if (!m_bIsLink || m_nObjectState == -1)
+ if (!m_bIsLinkURL || m_nObjectState == -1)
{
// it must be a linked initialized object
throw embed::WrongStateException(
@@ -1820,7 +1857,10 @@ void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XSt
else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
m_xDocHolder->Show();
- m_bIsLink = false;
+ // tdf#141529 reset all stuff involved in linked state, including
+ // the OLE content copied to the temp file
+ m_bIsLinkURL = false;
+ m_aLinkTempFile.clear();
m_aLinkFilterName.clear();
m_aLinkURL.clear();
}
@@ -1832,7 +1872,7 @@ sal_Bool SAL_CALL OCommonEmbeddedObject::isLink()
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
- return m_bIsLink;
+ return m_bIsLinkURL;
}
@@ -1842,7 +1882,7 @@ OUString SAL_CALL OCommonEmbeddedObject::getLinkURL()
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
- if ( !m_bIsLink )
+ if ( !m_bIsLinkURL )
throw embed::WrongStateException(
"The object is not a link object!",
static_cast< ::cppu::OWeakObject* >(this) );
diff --git a/embeddedobj/source/commonembedding/visobj.cxx b/embeddedobj/source/commonembedding/visobj.cxx
index 6306ecfad0cf..851457609e7d 100644
--- a/embeddedobj/source/commonembedding/visobj.cxx
+++ b/embeddedobj/source/commonembedding/visobj.cxx
@@ -55,7 +55,7 @@ void SAL_CALL OCommonEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const
changeState( embed::EmbedStates::RUNNING );
// the links should be switched back to loaded state for now to avoid locking problems
- bBackToLoaded = m_bIsLink;
+ bBackToLoaded = m_bIsLinkURL;
}
bool bSuccess = m_xDocHolder->SetExtent( nAspect, aSize );
@@ -88,7 +88,7 @@ awt::Size SAL_CALL OCommonEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
changeState( embed::EmbedStates::RUNNING );
// the links should be switched back to loaded state for now to avoid locking problems
- bBackToLoaded = m_bIsLink;
+ bBackToLoaded = m_bIsLinkURL;
}
awt::Size aResult;
@@ -128,7 +128,7 @@ sal_Int32 SAL_CALL OCommonEmbeddedObject::getMapUnit( sal_Int64 nAspect )
changeState( embed::EmbedStates::RUNNING );
// the links should be switched back to loaded state for now to avoid locking problems
- bBackToLoaded = m_bIsLink;
+ bBackToLoaded = m_bIsLinkURL;
}
sal_Int32 nResult = m_xDocHolder->GetMapUnit( nAspect );
@@ -172,7 +172,7 @@ embed::VisualRepresentation SAL_CALL OCommonEmbeddedObject::getPreferredVisualRe
setVisualAreaSize(nAspect, aOrigSize);
// the links should be switched back to loaded state for now to avoid locking problems
- bBackToLoaded = m_bIsLink;
+ bBackToLoaded = m_bIsLinkURL;
}
SAL_WARN_IF( !m_xDocHolder->GetComponent().is(), "embeddedobj.common", "Running or Active object has no component!" );
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 2294b0d7e915..1b020f430855 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -32,6 +32,7 @@
#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/util/XCloseable.hpp>
#include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp>
+#include <com/sun/star/io/XTempFile.hpp>
#include <cppuhelper/weak.hxx>
#include <rtl/ref.hxx>
#include <map>
@@ -132,7 +133,8 @@ protected:
css::awt::Rectangle m_aOwnRectangle;
css::awt::Rectangle m_aClipRectangle;
- bool m_bIsLink;
+ bool m_bIsLinkURL;
+ bool m_bLinkTempFileChanged;
// embedded object related stuff
OUString m_aEntryName;
@@ -146,6 +148,9 @@ protected:
bool m_bLinkHasPassword;
OUString m_aLinkPassword;
+ // tdf#141529 hold a cc of a linked OLE
+ css::uno::Reference < css::io::XTempFile > m_aLinkTempFile;
+
css::uno::Reference< css::uno::XInterface > m_xParent;
bool m_bHasClonedSize; // the object has cached size
commit a10f85209a722026d1e03364d508e89f32feb57b
Author: Armin Le Grand (Allotropia) <armin.le.grand at me.com>
AuthorDate: Wed Apr 7 11:15:04 2021 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Fri Apr 9 23:32:19 2021 +0200
tdf#141528 ensure that reset of linked state is executed
Take m_xDocHolder->GetComponent() and xModif->setModified
inside the local try..catch expression to ensure that the
reset of the linked state below (m_bIsLink and .clear())
is executed
Change-Id: I52d49569a43fd2c23dd997c7217f7552cbdcfb82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113722
Tested-by: Armin Le Grand <Armin.Le.Grand at me.com>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
(cherry picked from commit 2f665daa29dd5509b4ceb0461e76292e2262fa56)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113761
Tested-by: Jenkins
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index 3e4ab0dd989f..bf0bcdf2bbf2 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -1789,10 +1789,21 @@ void SAL_CALL OCommonEmbeddedObject::breakLink( const uno::Reference< embed::XSt
// TODO/LATER: handle the case when temp doc can not be created
// the document is a new embedded object so it must be marked as modified
uno::Reference< util::XCloseable > xDocument = CreateTempDocFromLink_Impl();
- uno::Reference< util::XModifiable > xModif( m_xDocHolder->GetComponent(), uno::UNO_QUERY_THROW );
try
{
- xModif->setModified( true );
+ if(m_xDocHolder.is() && m_xDocHolder->GetComponent().is())
+ {
+ // tdf#141528 m_xDocHolder->GetComponent() may be not set, so add it
+ // to the try path to not get thrown out of the local context to the next
+ // highter try...catch on the stack. To make breakLink work it is
+ // *necessary* to execute the code below that resets the linked state,
+ // esp. the *.clear stuff and resetting m_bIsLink.
+ uno::Reference< util::XModifiable > xModif( m_xDocHolder->GetComponent(), uno::UNO_QUERY_THROW );
+
+ // all other locations in this file check for xModif.is(), so do it here, too
+ if ( xModif.is() )
+ xModif->setModified( true );
+ }
}
catch( const uno::Exception& )
{}
More information about the Libreoffice-commits
mailing list