[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - cui/source cui/uiconfig include/svl include/unotools officecfg/registry sfx2/source svl/qa svl/source unotools/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 27 20:48:32 UTC 2019
cui/source/options/optfltr.cxx | 10 ++
cui/source/options/optfltr.hxx | 1
cui/uiconfig/ui/optfltrembedpage.ui | 63 +++++++++++--
include/svl/lockfilecommon.hxx | 2
include/svl/msodocumentlockfile.hxx | 8 +
include/unotools/fltrcfg.hxx | 3
officecfg/registry/schema/org/openoffice/Office/Common.xcs | 8 +
sfx2/source/doc/docfile.cxx | 46 +++++++++
svl/qa/unit/lockfiles/test_lockfiles.cxx | 2
svl/source/misc/lockfilecommon.cxx | 2
svl/source/misc/msodocumentlockfile.cxx | 19 ++-
unotools/source/config/fltrcfg.cxx | 25 ++++-
12 files changed, 165 insertions(+), 24 deletions(-)
New commits:
commit 5aa23e4d6e849f1ecccb2f6f290e7b34c9df7399
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Mar 27 15:52:32 2019 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Wed Mar 27 21:48:06 2019 +0100
Generate MSO lock files when the related MSO compat. option is set
Added a new compatibility option to the Tools -> Load / Save ->
Microsoft.
When this option is set on the UI or or set in the configuration files
LO generates lock files for MSO supported file formats, similar to
the lock files MSO generates itself.
Reviewed-on: https://gerrit.libreoffice.org/69678
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit 41dc917b9b55b8c0c4307ffc58a1fb7257df2b69)
Change-Id: I2f882723841162add01be9d3f7285a5162a60331
Reviewed-on: https://gerrit.libreoffice.org/69843
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx
index d1fd93342264..9c3c15d71e93 100644
--- a/cui/source/options/optfltr.cxx
+++ b/cui/source/options/optfltr.cxx
@@ -155,6 +155,7 @@ OfaMSFilterTabPage2::OfaMSFilterTabPage2( vcl::Window* pParent, const SfxItemSet
get( aHighlightingRB, "highlighting");
get( aShadingRB, "shading" );
+ get( aMSOLockFileCB, "mso_lockfile");
Size aControlSize(248, 55);
aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
@@ -185,6 +186,7 @@ void OfaMSFilterTabPage2::dispose()
m_pCheckLBContainer.clear();
aHighlightingRB.clear();
aShadingRB.clear();
+ aMSOLockFileCB.clear();
SfxTabPage::dispose();
}
@@ -254,6 +256,11 @@ bool OfaMSFilterTabPage2::FillItemSet( SfxItemSet* )
rOpt.SetCharBackground2Shading();
}
+ if( aMSOLockFileCB->IsValueChangedFromSaved() )
+ {
+ rOpt.EnableMSOLockFileCreation(aMSOLockFileCB->IsChecked());
+ }
+
return true;
}
@@ -320,6 +327,9 @@ void OfaMSFilterTabPage2::Reset( const SfxItemSet* )
aShadingRB->Check();
aHighlightingRB->SaveValue();
+
+ aMSOLockFileCB->Check(rOpt.IsMSOLockFileCreationIsEnabled());
+ aMSOLockFileCB->SaveValue();
}
void OfaMSFilterTabPage2::InsertEntry( const OUString& _rTxt, sal_IntPtr _nType )
diff --git a/cui/source/options/optfltr.hxx b/cui/source/options/optfltr.hxx
index 4ef6cf3a63c0..aa5d89f23123 100644
--- a/cui/source/options/optfltr.hxx
+++ b/cui/source/options/optfltr.hxx
@@ -86,6 +86,7 @@ class OfaMSFilterTabPage2 : public SfxTabPage
VclPtr<RadioButton> aHighlightingRB;
VclPtr<RadioButton> aShadingRB;
+ VclPtr<CheckBox> aMSOLockFileCB;
virtual ~OfaMSFilterTabPage2() override;
virtual void dispose() override;
diff --git a/cui/uiconfig/ui/optfltrembedpage.ui b/cui/uiconfig/ui/optfltrembedpage.ui
index 811ecdc990ff..059d20cbf778 100644
--- a/cui/uiconfig/ui/optfltrembedpage.ui
+++ b/cui/uiconfig/ui/optfltrembedpage.ui
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
<interface domain="cui">
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires LibreOffice 1.0 -->
@@ -48,8 +49,8 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="optfltrembedpage|label2">[L]: Load and convert the object</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -61,8 +62,8 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="optfltrembedpage|label3">[S]: Convert and save the object</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
@@ -88,8 +89,6 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -182,8 +181,60 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkButtonBox" id="buttonbox2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkCheckButton" id="mso_lockfile">
+ <property name="label" translatable="yes" context="optfltrembedpage|mso_lockfile">Create MSO lock file</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="optfltrembedpage|label5">Lock files</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
</packing>
</child>
</object>
diff --git a/include/svl/lockfilecommon.hxx b/include/svl/lockfilecommon.hxx
index f66fb135139c..ecfdee26d0e2 100644
--- a/include/svl/lockfilecommon.hxx
+++ b/include/svl/lockfilecommon.hxx
@@ -72,7 +72,7 @@ public:
static OUString GetCurrentLocalTime();
static LockFileEntry GenerateOwnEntry();
- INetURLObject ResolveLinks( const INetURLObject& aDocURL ) const;
+ static INetURLObject ResolveLinks( const INetURLObject& aDocURL );
};
}
diff --git a/include/svl/msodocumentlockfile.hxx b/include/svl/msodocumentlockfile.hxx
index 75f03ff16d4b..2c438f0178cb 100644
--- a/include/svl/msodocumentlockfile.hxx
+++ b/include/svl/msodocumentlockfile.hxx
@@ -55,9 +55,9 @@ class SVL_DLLPUBLIC MSODocumentLockFile : public GenDocumentLockFile
private:
OUString m_sOrigURL;
- bool isWordFormat(const OUString& aOrigURL) const;
- bool isExcelFormat(const OUString& aOrigURL) const;
- bool isPowerPointFormat(const OUString& aOrigURL) const;
+ static bool isWordFormat(const OUString& aOrigURL);
+ static bool isExcelFormat(const OUString& aOrigURL);
+ static bool isPowerPointFormat(const OUString& aOrigURL);
protected:
virtual void
@@ -74,6 +74,8 @@ public:
virtual LockFileEntry GetLockData() override;
virtual void RemoveFile() override;
+
+ static bool IsMSOSupportedFileFormat(const OUString& aURL);
};
} // namespace svt
diff --git a/include/unotools/fltrcfg.hxx b/include/unotools/fltrcfg.hxx
index ab0eb1364e81..bc5630cac444 100644
--- a/include/unotools/fltrcfg.hxx
+++ b/include/unotools/fltrcfg.hxx
@@ -91,6 +91,9 @@ public:
void SetCharBackground2Highlighting();
void SetCharBackground2Shading();
+ bool IsMSOLockFileCreationIsEnabled() const;
+ void EnableMSOLockFileCreation(bool bEnable);
+
static SvtFilterOptions& Get();
};
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 05dc0012b1ab..6aee83bbce97 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -3776,6 +3776,14 @@
</info>
<value>true</value>
</prop>
+ <prop oor:name="CreateMSOLockFiles" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Specifies if LO should create MSO lock files next to the LO lock files
+ when openning a file. This makes MSO to be able to read the user name from
+ the lock file and show it for the user.</desc>
+ </info>
+ <value>false</value>
+ </prop>
</group>
<group oor:name="Export">
<info>
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 44c8a08a8293..e55bd203a9b5 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -110,6 +110,7 @@
#include <sot/storage.hxx>
#include <unotools/saveopt.hxx>
#include <svl/documentlockfile.hxx>
+#include <svl/msodocumentlockfile.hxx>
#include <com/sun/star/document/DocumentRevisionListPersistence.hpp>
#include <helper.hxx>
@@ -126,6 +127,7 @@
#include <sfx2/sfxresid.hxx>
#include <officecfg/Office/Common.hxx>
#include <comphelper/propertysequence.hxx>
+#include <unotools/fltrcfg.hxx>
#include <com/sun/star/io/WrongFormatException.hpp>
@@ -188,6 +190,7 @@ public:
bool m_bSalvageMode:1;
bool m_bVersionsAlreadyLoaded:1;
bool m_bLocked:1;
+ bool m_bMSOLockFileCreated : 1;
bool m_bDisableUnlockWebDAV:1;
bool m_bGotDateTime:1;
bool m_bRemoveBackup:1;
@@ -267,6 +270,7 @@ SfxMedium_Impl::SfxMedium_Impl() :
m_bSalvageMode( false ),
m_bVersionsAlreadyLoaded( false ),
m_bLocked( false ),
+ m_bMSOLockFileCreated( false ),
m_bDisableUnlockWebDAV( false ),
m_bGotDateTime( false ),
m_bRemoveBackup( false ),
@@ -1347,6 +1351,15 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand( bool bLoading, bool b
try
{
::svt::DocumentLockFile aLockFile( pImpl->m_aLogicName );
+
+ std::unique_ptr<svt::MSODocumentLockFile> pMSOLockFile;
+ const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
+ if (rOpt.IsMSOLockFileCreationIsEnabled() && svt::MSODocumentLockFile::IsMSOSupportedFileFormat(pImpl->m_aLogicName))
+ {
+ pMSOLockFile.reset(new svt::MSODocumentLockFile(pImpl->m_aLogicName));
+ pImpl->m_bMSOLockFileCreated = true;
+ }
+
bool bIoErr = false;
if (!bHandleSysLocked)
@@ -1354,6 +1367,8 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand( bool bLoading, bool b
try
{
bResult = aLockFile.CreateOwnLockFile();
+ if(pMSOLockFile)
+ bResult &= pMSOLockFile->CreateOwnLockFile();
}
catch (const uno::Exception&)
{
@@ -1378,6 +1393,9 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand( bool bLoading, bool b
bResult = true;
// take the ownership over the lock file
aLockFile.OverwriteOwnLockFile();
+
+ if(pMSOLockFile)
+ pMSOLockFile->OverwriteOwnLockFile();
}
}
@@ -1433,6 +1451,9 @@ SfxMedium::LockFileResult SfxMedium::LockOrigFileOnDemand( bool bLoading, bool b
{
// take the ownership over the lock file
bResult = aLockFile.OverwriteOwnLockFile();
+
+ if(pMSOLockFile)
+ pMSOLockFile->OverwriteOwnLockFile();
}
else if (bLoading && !bHandleSysLocked)
eResult = LockFileResult::FailedLockFile;
@@ -2980,6 +3001,31 @@ void SfxMedium::UnlockFile( bool bReleaseLockStream )
catch( const uno::Exception& )
{}
}
+
+ if(pImpl->m_bMSOLockFileCreated)
+ {
+ ::svt::MSODocumentLockFile aMSOLockFile( pImpl->m_aLogicName );
+
+ try
+ {
+ pImpl->m_bLocked = false;
+ // TODO/LATER: A warning could be shown in case the file is not the own one
+ aMSOLockFile.RemoveFile();
+ }
+ catch( const io::WrongFormatException& )
+ {
+ try
+ {
+ // erase the empty or corrupt file
+ aMSOLockFile.RemoveFileDirectly();
+ }
+ catch( const uno::Exception& )
+ {}
+ }
+ catch( const uno::Exception& )
+ {}
+ pImpl->m_bMSOLockFileCreated = false;
+ }
#endif
}
diff --git a/svl/qa/unit/lockfiles/test_lockfiles.cxx b/svl/qa/unit/lockfiles/test_lockfiles.cxx
index 8083c143f461..5f23240f387c 100644
--- a/svl/qa/unit/lockfiles/test_lockfiles.cxx
+++ b/svl/qa/unit/lockfiles/test_lockfiles.cxx
@@ -88,7 +88,7 @@ OUString readLockFile(const OUString& aSource)
OUString GetLockFileName(const svt::GenDocumentLockFile& rLockFile)
{
- INetURLObject aDocURL = rLockFile.ResolveLinks(INetURLObject(rLockFile.GetURL()));
+ INetURLObject aDocURL = svt::LockFileCommon::ResolveLinks(INetURLObject(rLockFile.GetURL()));
return aDocURL.GetName();
}
diff --git a/svl/source/misc/lockfilecommon.cxx b/svl/source/misc/lockfilecommon.cxx
index d98201402cdb..cf77c7286b58 100644
--- a/svl/source/misc/lockfilecommon.cxx
+++ b/svl/source/misc/lockfilecommon.cxx
@@ -96,7 +96,7 @@ OUString LockFileCommon::GenerateURL( const OUString& aOrigURL, const OUString&
}
-INetURLObject LockFileCommon::ResolveLinks( const INetURLObject& aDocURL ) const
+INetURLObject LockFileCommon::ResolveLinks( const INetURLObject& aDocURL )
{
if ( aDocURL.HasError() )
throw lang::IllegalArgumentException();
diff --git a/svl/source/misc/msodocumentlockfile.cxx b/svl/source/misc/msodocumentlockfile.cxx
index 938b36d5cd26..e1afd70ef2e8 100644
--- a/svl/source/misc/msodocumentlockfile.cxx
+++ b/svl/source/misc/msodocumentlockfile.cxx
@@ -18,9 +18,9 @@
namespace svt
{
-bool MSODocumentLockFile::isWordFormat(const OUString& aOrigURL) const
+bool MSODocumentLockFile::isWordFormat(const OUString& aOrigURL)
{
- INetURLObject aDocURL = ResolveLinks(INetURLObject(aOrigURL));
+ INetURLObject aDocURL = LockFileCommon::ResolveLinks(INetURLObject(aOrigURL));
return aDocURL.GetFileExtension().compareToIgnoreAsciiCase("DOC") == 0
|| aDocURL.GetFileExtension().compareToIgnoreAsciiCase("DOCX") == 0
@@ -28,18 +28,18 @@ bool MSODocumentLockFile::isWordFormat(const OUString& aOrigURL) const
|| aDocURL.GetFileExtension().compareToIgnoreAsciiCase("ODT") == 0;
}
-bool MSODocumentLockFile::isExcelFormat(const OUString& aOrigURL) const
+bool MSODocumentLockFile::isExcelFormat(const OUString& aOrigURL)
{
- INetURLObject aDocURL = ResolveLinks(INetURLObject(aOrigURL));
+ INetURLObject aDocURL = LockFileCommon::ResolveLinks(INetURLObject(aOrigURL));
return //aDocURL.GetFileExtension().compareToIgnoreAsciiCase("XLS") || // MSO does not create lockfile for XLS
aDocURL.GetFileExtension().compareToIgnoreAsciiCase("XLSX") == 0
|| aDocURL.GetFileExtension().compareToIgnoreAsciiCase("ODS") == 0;
}
-bool MSODocumentLockFile::isPowerPointFormat(const OUString& aOrigURL) const
+bool MSODocumentLockFile::isPowerPointFormat(const OUString& aOrigURL)
{
- INetURLObject aDocURL = ResolveLinks(INetURLObject(aOrigURL));
+ INetURLObject aDocURL = LockFileCommon::ResolveLinks(INetURLObject(aOrigURL));
return aDocURL.GetFileExtension().compareToIgnoreAsciiCase("PPTX") == 0
|| aDocURL.GetFileExtension().compareToIgnoreAsciiCase("PPT") == 0
@@ -56,7 +56,7 @@ MSODocumentLockFile::~MSODocumentLockFile() {}
OUString MSODocumentLockFile::GenerateURL(const OUString& aOrigURL, const OUString& aPrefix)
{
- INetURLObject aDocURL = ResolveLinks(INetURLObject(aOrigURL));
+ INetURLObject aDocURL = LockFileCommon::ResolveLinks(INetURLObject(aOrigURL));
OUString aURL = aDocURL.GetPartBeforeLastName();
aURL += aPrefix;
@@ -239,6 +239,11 @@ void MSODocumentLockFile::RemoveFile()
RemoveFileDirectly();
}
+bool MSODocumentLockFile::IsMSOSupportedFileFormat(const OUString& aURL)
+{
+ return isWordFormat(aURL) || isExcelFormat(aURL) || isPowerPointFormat(aURL);
+}
+
} // namespace svt
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/unotools/source/config/fltrcfg.cxx b/unotools/source/config/fltrcfg.cxx
index 32a61fdae8a1..4993902aa786 100644
--- a/unotools/source/config/fltrcfg.cxx
+++ b/unotools/source/config/fltrcfg.cxx
@@ -25,6 +25,7 @@
#include <tools/debug.hxx>
#include <tools/solar.h>
#include <osl/diagnose.h>
+#include <sal/log.hxx>
#include <com/sun/star/uno/Sequence.hxx>
@@ -54,10 +55,11 @@ enum class ConfigFlags {
UseEnhancedFields = 0x0100000,
WordWbctbl = 0x0200000,
SmartArtShapeLoad = 0x0400000,
- CharBackgroundToHighlighting = 0x8000000
+ CharBackgroundToHighlighting = 0x8000000,
+ CreateMSOLockFiles = 0x2000000
};
namespace o3tl {
- template<> struct typed_flags<ConfigFlags> : is_typed_flags<ConfigFlags, 0x87fff3f> {};
+ template<> struct typed_flags<ConfigFlags> : is_typed_flags<ConfigFlags, 0xf7fff3f> {};
}
class SvtAppFilterOptions_Impl : public utl::ConfigItem
@@ -246,7 +248,8 @@ struct SvtFilterOptions_Impl
ConfigFlags::ImpressSave |
ConfigFlags::UseEnhancedFields |
ConfigFlags::SmartArtShapeLoad |
- ConfigFlags::CharBackgroundToHighlighting;
+ ConfigFlags::CharBackgroundToHighlighting|
+ ConfigFlags::CreateMSOLockFiles;
Load();
}
@@ -306,7 +309,7 @@ const Sequence<OUString>& GetPropertyNames()
static Sequence<OUString> aNames;
if(!aNames.getLength())
{
- int nCount = 14;
+ int nCount = 15;
aNames.realloc(nCount);
static const char* aPropNames[] =
{
@@ -324,6 +327,7 @@ const Sequence<OUString>& GetPropertyNames()
"Import/ImportWWFieldsAsEnhancedFields", // 11
"Import/SmartArtToShapes", // 12
"Export/CharBackgroundToHighlighting" // 13
+ "Import/CreateMSOLockFiles" // 14
};
OUString* pNames = aNames.getArray();
for(int i = 0; i < nCount; i++)
@@ -365,6 +369,7 @@ static ConfigFlags lcl_GetFlag(sal_Int32 nProp)
case 11: nFlag = ConfigFlags::UseEnhancedFields; break;
case 12: nFlag = ConfigFlags::SmartArtShapeLoad; break;
case 13: nFlag = ConfigFlags::CharBackgroundToHighlighting; break;
+ case 14: nFlag = ConfigFlags::CreateMSOLockFiles; break;
default: OSL_FAIL("illegal value");
}
@@ -632,7 +637,6 @@ bool SvtFilterOptions::IsEnableWordPreview() const
return pImpl->IsFlag( ConfigFlags::EnableWordPreview );
}
-
bool SvtFilterOptions::IsCharBackground2Highlighting() const
{
return pImpl->IsFlag( ConfigFlags::CharBackgroundToHighlighting );
@@ -655,4 +659,15 @@ void SvtFilterOptions::SetCharBackground2Shading()
SetModified();
}
+bool SvtFilterOptions::IsMSOLockFileCreationIsEnabled() const
+{
+ return pImpl->IsFlag( ConfigFlags::CreateMSOLockFiles );
+}
+
+void SvtFilterOptions::EnableMSOLockFileCreation(bool bEnable)
+{
+ pImpl->SetFlag( ConfigFlags::CreateMSOLockFiles, bEnable );
+ SetModified();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list