summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfx2/source/view/sfxbasecontroller.cxx12
-rw-r--r--sw/qa/uibase/uiview/data/update-replacement-nosetting.odtbin0 -> 40982 bytes
-rw-r--r--sw/qa/uibase/uiview/uiview.cxx25
-rw-r--r--sw/source/uibase/uiview/view.cxx2
4 files changed, 34 insertions, 5 deletions
diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx
index cecf046bfbe9..23b1aad5c3d0 100644
--- a/sfx2/source/view/sfxbasecontroller.cxx
+++ b/sfx2/source/view/sfxbasecontroller.cxx
@@ -1334,12 +1334,18 @@ void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect )
break;
}
}
- if ( nViewDataIndex < nCount )
+ if (nViewDataIndex < nCount || !xViewData.is())
{
Sequence< PropertyValue > aViewData;
- OSL_VERIFY( xViewData->getByIndex( nViewDataIndex ) >>= aViewData );
- if ( aViewData.hasElements() )
+ if (xViewData.is())
+ {
+ OSL_VERIFY(xViewData->getByIndex(nViewDataIndex) >>= aViewData);
+ }
+ if (aViewData.hasElements() || !xViewData.is())
+ {
+ // Tolerate empty xViewData, ReadUserDataSequence() has side effects.
m_pData->m_pViewShell->ReadUserDataSequence( aViewData );
+ }
}
}
catch (const Exception&)
diff --git a/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt b/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt
new file mode 100644
index 000000000000..055c3d1a2c2a
--- /dev/null
+++ b/sw/qa/uibase/uiview/data/update-replacement-nosetting.odt
Binary files differ
diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx
index 8827cea10752..4d622aafaa5f 100644
--- a/sw/qa/uibase/uiview/uiview.cxx
+++ b/sw/qa/uibase/uiview/uiview.cxx
@@ -12,6 +12,7 @@
#include <unotools/mediadescriptor.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
@@ -87,6 +88,30 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateAllObjectReplacements)
CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components_1"));
}
+CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testUpdateReplacementNosetting)
+{
+ // Load a copy of the document in hidden mode.
+ OUString aSourceURL
+ = m_directories.getURLFromSrc(DATA_DIRECTORY) + "update-replacement-nosetting.odt";
+ CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, osl::File::copy(aSourceURL, maTempFile.GetURL()));
+ mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument",
+ { comphelper::makePropertyValue("Hidden", true) });
+
+ // Update "everything" (including object replacements) and save it.
+ dispatchCommand(mxComponent, ".uno:UpdateAll", {});
+ uno::Reference<frame::XStorable2> xStorable(mxComponent, uno::UNO_QUERY);
+ xStorable->storeSelf({});
+
+ // Check the contents of the updated copy.
+ uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+ = packages::zip::ZipFileAccess::createWithURL(xContext, maTempFile.GetURL());
+
+ // Without the accompanying fix in place, this test would have failed, because the embedded
+ // object replacement image was not generated.
+ CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Components"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 2b5670cffc11..0e12a868f88d 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1283,8 +1283,6 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
if(GetDocShell()->IsPreview()||m_bIsPreviewDoubleClick)
return;
bool bIsOwnDocument = lcl_IsOwnDocument( *this );
- if (!rSequence.hasElements())
- return;
CurrShell aCurr(m_pWrtShell.get());
const SwRect& rRect = m_pWrtShell->GetCharRect();