summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sfx2/sfxsids.hrc3
-rw-r--r--sfx2/qa/cppunit/misc/hello.odtbin0 -> 8159 bytes
-rw-r--r--sfx2/qa/cppunit/test_misc.cxx38
-rw-r--r--sfx2/sdi/sfx.sdi2
-rw-r--r--sfx2/source/appl/appuno.cxx1
-rw-r--r--sfx2/source/doc/objstor.cxx11
6 files changed, 53 insertions, 2 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 81d4d45cbe9d..6fbdaa4f281e 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -244,8 +244,9 @@
#define SID_TEMPLATE_MANAGER (SID_SFX_START + 1727)
#define SID_TOOLBAR_MODE (SID_SFX_START + 1728)
#define SID_NO_FILE_SYNC (SID_SFX_START + 1729)
+#define SID_NO_THUMBNAIL (SID_SFX_START + 1730)
-// SID_SFX_free_START (SID_SFX_START + 1730)
+// SID_SFX_free_START (SID_SFX_START + 1731)
// SID_SFX_free_END (SID_SFX_START + 3999)
#define SID_OPEN_NEW_VIEW (SID_SFX_START + 520)
diff --git a/sfx2/qa/cppunit/misc/hello.odt b/sfx2/qa/cppunit/misc/hello.odt
new file mode 100644
index 000000000000..23ce6a4db9af
--- /dev/null
+++ b/sfx2/qa/cppunit/misc/hello.odt
Binary files differ
diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx
index e3cbd8d4748c..5f36b438f089 100644
--- a/sfx2/qa/cppunit/test_misc.cxx
+++ b/sfx2/qa/cppunit/test_misc.cxx
@@ -20,11 +20,17 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
#include <test/bootstrapfixture.hxx>
#include <test/xmltesttools.hxx>
+#include <unotest/macros_test.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/app.hxx>
using namespace ::com::sun::star;
@@ -34,10 +40,13 @@ namespace {
class MiscTest
: public test::BootstrapFixture
+ , public unotest::MacrosTest
, public XmlTestTools
{
public:
+ virtual void setUp() override;
void testODFCustomMetadata();
+ void testNoThumbnail();
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override
{
@@ -52,11 +61,19 @@ public:
CPPUNIT_TEST_SUITE(MiscTest);
CPPUNIT_TEST(testODFCustomMetadata);
+ CPPUNIT_TEST(testNoThumbnail);
CPPUNIT_TEST_SUITE_END();
private:
};
+void MiscTest::setUp()
+{
+ m_xContext = comphelper::getProcessComponentContext();
+ mxDesktop.set(frame::Desktop::create(m_xContext));
+ SfxApplication::GetOrCreate();
+}
+
void MiscTest::testODFCustomMetadata()
{
uno::Reference<document::XDocumentProperties> const xProps(
@@ -86,6 +103,27 @@ void MiscTest::testODFCustomMetadata()
aTempFile.EnableKillingFile();
}
+void MiscTest::testNoThumbnail()
+{
+ // Load a document.
+ const OUString aURL(m_directories.getURLFromSrc("/sfx2/qa/cppunit/misc/hello.odt"));
+ uno::Reference<lang::XComponent> xComponent
+ = loadFromDesktop(aURL, "com.sun.star.text.TextDocument");
+ CPPUNIT_ASSERT(xComponent.is());
+
+ // Save it with the NoThumbnail option and assert that it has no thumbnail.
+ uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xStorable.is());
+ utl::TempFile aTempFile;
+ uno::Sequence<beans::PropertyValue> aProperties(
+ comphelper::InitPropertySequence({ { "NoThumbnail", uno::makeAny(true) } }));
+ xStorable->storeToURL(aTempFile.GetURL(), aProperties);
+ uno::Reference<packages::zip::XZipFileAccess2> xZipFile
+ = packages::zip::ZipFileAccess::createWithURL(m_xContext, aTempFile.GetURL());
+ CPPUNIT_ASSERT(!xZipFile->hasByName("Thumbnails/thumbnail.png"));
+
+ xComponent->dispose();
+}
CPPUNIT_TEST_SUITE_REGISTRATION(MiscTest);
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index a366a271edb5..0ddf3653c3c0 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3557,7 +3557,7 @@ SfxVoidItem SaveAll SID_SAVEDOCS
SfxStringItem SaveAs SID_SAVEASDOC
-(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxBoolItem NoFileSync SID_NO_FILE_SYNC)
+(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxBoolItem NoFileSync SID_NO_FILE_SYNC,SfxBoolItem NoThumbnail SID_NO_THUMBNAIL)
[
AutoUpdate = FALSE,
FastCall = FALSE,
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 8b3d0792f70d..5b50b2e7a145 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -106,6 +106,7 @@ SfxFormalArgument const aFormalArgs[] = {
{ reinterpret_cast<SfxType*>(&aSfxInt16Item_Impl), "Version", SID_VERSION },
{ reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM },
{ reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoFileSync", SID_NO_FILE_SYNC },
+ { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoThumbnail", SID_NO_THUMBNAIL },
};
static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index b470d8f60177..44f6f1556f75 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -100,6 +100,7 @@
#include <basic/modsizeexceeded.hxx>
#include <officecfg/Office/Common.hxx>
#include <osl/file.hxx>
+#include <comphelper/scopeguard.hxx>
#include <sfx2/signaturestate.hxx>
#include <sfx2/app.hxx>
@@ -2743,6 +2744,16 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString&
if (pNoFileSync && pNoFileSync->GetValue())
pNewFile->DisableFileSync(true);
+ bool bUseThumbnailSave = IsUseThumbnailSave();
+ comphelper::ScopeGuard aThumbnailGuard(
+ [this, bUseThumbnailSave] { this->SetUseThumbnailSave(bUseThumbnailSave); });
+ const SfxBoolItem* pNoThumbnail = pMergedParams->GetItem<SfxBoolItem>(SID_NO_THUMBNAIL, false);
+ if (pNoThumbnail)
+ // Thumbnail generation should be avoided just for this save.
+ SetUseThumbnailSave(!pNoThumbnail->GetValue());
+ else
+ aThumbnailGuard.dismiss();
+
// set filter; if no filter is given, take the default filter of the factory
if ( !aFilterName.isEmpty() )
pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) );