Rebased ref, commits from common ancestor: commit fec9070133e89d7d02e20cb7f1dd8b07d3ba62a9 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Apr 3 09:39:53 2023 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon May 1 19:22:30 2023 +0100
BinaryDataContainer swap out implementation. We can easily accumulate a large number of in-memory graphic objects, and swapping these as well as the un-compressed images can become important. Despite the shared pImpl, we retained the reference counting on the underling vector to keep this immutable while we hand out a MemoryStream reference to it. Change-Id: Ib7ca45afb8499460b1852461f7c11afca3f3cdfa Signed-off-by: Michael Meeks <michael.me...@collabora.com> diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx index e178ad6c4d62..f6f07f0c5ef6 100644 --- a/include/vcl/BinaryDataContainer.hxx +++ b/include/vcl/BinaryDataContainer.hxx @@ -13,6 +13,7 @@ #include <sal/config.h> #include <com/sun/star/uno/Sequence.hxx> +#include <unotools/tempfile.hxx> #include <tools/stream.hxx> #include <vcl/dllapi.h> @@ -26,9 +27,11 @@ */ class VCL_DLLPUBLIC BinaryDataContainer final { -private: - // the binary data - std::shared_ptr<std::vector<sal_uInt8>> mpData; + struct Impl; + + std::shared_ptr<Impl> mpImpl; + + void ensureSwappedIn() const; public: BinaryDataContainer() = default; @@ -56,6 +59,9 @@ public: /// return the in-memory size in bytes as of now. std::size_t getSizeBytes() const; + /// swap out to disk for now + void swapOut() const; + size_t calculateHash() const; }; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 76598c9945e1..ce49a8e42706 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -1253,6 +1253,9 @@ bool ImpGraphic::swapOutGraphic(SvStream& rStream) break; } + if (mpGfxLink) + mpGfxLink->getDataContainer().swapOut(); + return true; } diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx index 31561d9e16e3..a99cae99e023 100644 --- a/vcl/source/graphic/BinaryDataContainer.cxx +++ b/vcl/source/graphic/BinaryDataContainer.cxx @@ -10,21 +10,75 @@ #include <vcl/BinaryDataContainer.hxx> #include <o3tl/hash_combine.hxx> +#include <unotools/tempfile.hxx> +#include <comphelper/lok.hxx> +#include <sal/log.hxx> + +struct BinaryDataContainer::Impl +{ + // temp file to store the data out of RAM if necessary + std::unique_ptr<utl::TempFileNamed> mpFile; + // the binary data + std::shared_ptr<std::vector<sal_uInt8>> mpData; + + /// Populate mpData from the stream + void readData(SvStream& stream, size_t size) + { + auto pData = std::make_shared<std::vector<sal_uInt8>>(size); + if (stream.ReadBytes(pData->data(), pData->size()) == size) + mpData = std::move(pData); + } + + /// ensure the data is in-RAM + void ensureSwappedIn() + { + if (mpData || !mpFile) + return; + + auto pStream = mpFile->GetStream(StreamMode::READ); + pStream->Seek(0); + readData(*pStream, pStream->remainingSize()); + + // Horrifying data loss ... + SAL_WARN_IF(pStream->GetError(), "vcl", + "Inconsistent system - failed to swap image back in"); + SAL_DEBUG("Swap in: " << pStream->GetError()); + } + + void swapOut() + { + if (mpFile) + { + // we already have it swapped out. + mpData.reset(); + return; + } + + if (!mpData || mpData->empty()) + return; + + mpFile.reset(new utl::TempFileNamed()); + auto pStream = mpFile->GetStream(StreamMode::READWRITE); + + pStream->WriteBytes(mpData->data(), mpData->size()); + + mpData.reset(); + } +}; BinaryDataContainer::BinaryDataContainer(SvStream& stream, size_t size) { - auto pBuffer = std::make_shared<std::vector<sal_uInt8>>(size); - if (stream.ReadBytes(pBuffer->data(), pBuffer->size()) == size) - mpData = std::move(pBuffer); + mpImpl.reset(new Impl()); + mpImpl->readData(stream, size); } size_t BinaryDataContainer::calculateHash() const { size_t nSeed = 0; - if (mpData) + if (mpImpl && mpImpl->mpData && !mpImpl->mpData->empty()) { o3tl::hash_combine(nSeed, getSize()); - for (sal_uInt8 const& rByte : *mpData) + for (sal_uInt8 const& rByte : *mpImpl->mpData) o3tl::hash_combine(nSeed, rByte); } return nSeed; @@ -34,10 +88,11 @@ css::uno::Sequence<sal_Int8> BinaryDataContainer::getCopyAsByteSequence() const { if (isEmpty()) return css::uno::Sequence<sal_Int8>(); + assert(mpImpl); css::uno::Sequence<sal_Int8> aData(getSize()); - std::copy(mpData->cbegin(), mpData->cend(), aData.getArray()); + std::copy(mpImpl->mpData->cbegin(), mpImpl->mpData->cend(), aData.getArray()); return aData; } @@ -53,10 +108,9 @@ class ReferencedMemoryStream : public SvMemoryStream std::shared_ptr<std::vector<sal_uInt8>> mpData; public: - ReferencedMemoryStream(const std::shared_ptr<std::vector<sal_uInt8>>& rData) - : SvMemoryStream(rData ? rData->data() : nullptr, rData ? rData->size() : 0, - StreamMode::READ) - , mpData(rData) + ReferencedMemoryStream(const std::shared_ptr<std::vector<sal_uInt8>>& pData) + : SvMemoryStream(mpData->data(), mpData->size(), StreamMode::READ) + , mpData(pData) { } }; @@ -64,20 +118,52 @@ public: std::shared_ptr<SvStream> BinaryDataContainer::getAsStream() { - return std::make_shared<ReferencedMemoryStream>(mpData); + ensureSwappedIn(); // TODO: transfer in streamed chunks + return std::make_shared<ReferencedMemoryStream>(mpImpl->mpData); } std::size_t BinaryDataContainer::writeToStream(SvStream& rStream) const { + ensureSwappedIn(); // TODO: transfer in streamed chunks return rStream.WriteBytes(getData(), getSize()); } -size_t BinaryDataContainer::getSize() const { return mpData ? mpData->size() : 0; } +size_t BinaryDataContainer::getSize() const +{ + ensureSwappedIn(); + return mpImpl && mpImpl->mpData ? mpImpl->mpData->size() : 0; +} -size_t BinaryDataContainer::getSizeBytes() const { return getSize(); } +size_t BinaryDataContainer::getSizeBytes() const +{ + return mpImpl && mpImpl->mpData ? mpImpl->mpData->size() : 0; +} -bool BinaryDataContainer::isEmpty() const { return !mpData || mpData->empty(); } +bool BinaryDataContainer::isEmpty() const +{ + ensureSwappedIn(); + return !mpImpl || !mpImpl->mpData || mpImpl->mpData->empty(); +} -const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? mpData->data() : nullptr; } +const sal_uInt8* BinaryDataContainer::getData() const +{ + ensureSwappedIn(); + return mpImpl && mpImpl->mpData ? mpImpl->mpData->data() : nullptr; +} + +void BinaryDataContainer::ensureSwappedIn() const +{ + if (mpImpl) + mpImpl->ensureSwappedIn(); +} + +void BinaryDataContainer::swapOut() const +{ + // Only bother reducing memory footprint in kit mode - for mobile/online etc. + if (!mpImpl || !comphelper::LibreOfficeKit::isActive()) + return; + + mpImpl->swapOut(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 6810d0f5b61a779588261e8ff848b9274a4cec98 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Apr 3 09:34:54 2023 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Thu Apr 27 11:25:41 2023 +0100 BinaryDataContainer: account for in-memory size of un-compressed image. Change-Id: Ia86d4dda706959bb58e941e65f2b2f7fffa8dc3d Signed-off-by: Michael Meeks <michael.me...@collabora.com> diff --git a/include/vcl/BinaryDataContainer.hxx b/include/vcl/BinaryDataContainer.hxx index e9e46a04e667..e178ad6c4d62 100644 --- a/include/vcl/BinaryDataContainer.hxx +++ b/include/vcl/BinaryDataContainer.hxx @@ -53,6 +53,9 @@ public: /// writes the contents to the given stream std::size_t writeToStream(SvStream& rStream) const; + /// return the in-memory size in bytes as of now. + std::size_t getSizeBytes() const; + size_t calculateHash() const; }; diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx index 8c0f5fd32b05..531633b3f738 100644 --- a/include/vcl/gfxlink.hxx +++ b/include/vcl/gfxlink.hxx @@ -85,6 +85,9 @@ public: sal_uInt32 GetDataSize() const { return maDataContainer.getSize(); } const sal_uInt8* GetData() const; + /// return the in-memory size as of now. + size_t getSizeBytes() const { return maDataContainer.getSizeBytes(); } + const BinaryDataContainer& getDataContainer() const { return maDataContainer; diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 84df1765569c..76598c9945e1 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -999,6 +999,9 @@ sal_uLong ImpGraphic::getSizeBytes() const break; } + if (mpGfxLink) + mnSizeBytes += mpGfxLink->getSizeBytes(); + return mnSizeBytes; } @@ -1431,6 +1434,8 @@ void ImpGraphic::dumpState(rtl::OStringBuffer &rState) rState.append(static_cast<sal_Int32>(meType)); rState.append("\tsize:\t"); rState.append(static_cast<sal_Int64>(mnSizeBytes)); + rState.append("\tgfxl:\t"); + rState.append(static_cast<sal_Int64>(mpGfxLink ? mpGfxLink->getSizeBytes() : -1)); rState.append("\t"); rState.append(static_cast<sal_Int32>(maSwapInfo.maSizePixel.Width())); rState.append("x"); diff --git a/vcl/source/graphic/BinaryDataContainer.cxx b/vcl/source/graphic/BinaryDataContainer.cxx index b35195b7d27e..31561d9e16e3 100644 --- a/vcl/source/graphic/BinaryDataContainer.cxx +++ b/vcl/source/graphic/BinaryDataContainer.cxx @@ -74,6 +74,8 @@ std::size_t BinaryDataContainer::writeToStream(SvStream& rStream) const size_t BinaryDataContainer::getSize() const { return mpData ? mpData->size() : 0; } +size_t BinaryDataContainer::getSizeBytes() const { return getSize(); } + bool BinaryDataContainer::isEmpty() const { return !mpData || mpData->empty(); } const sal_uInt8* BinaryDataContainer::getData() const { return mpData ? mpData->data() : nullptr; } commit 4b6b9411e4ac912817dd804782ad2054bc0d1660 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Apr 27 08:15:51 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Apr 27 12:21:30 2023 +0200 sw floattable, crashtesting: fix PDF export of fdo72790-1.docx, part 4 Converting the bugdoc to PDF crashed Writer layout since commit ce3308a926f036b87515b8cd97d2b197063dc77a (tdf#61594 sw floattable: import floating tables as split flys by default, 2023-04-12). Part 1 already fixed the crash and parts 2-3 already improved the layout partially, towards avoiding a layout loop. The top problem now seems to be that page breaks before floating tables are ignored, which leads to a layout situation that loops. This problem was hidden before, since page breaks were not ignored. Fix the problem at DOCX import time: if there is a "break before" on the table, then transfer that to the anchor paragraph, which gives the correct layout, and also side-steps the above described layout loop. We should probably never call SwTextFrame::JoinFrame() when creating the initial layout for a document, that part is still unfixed, but that looks like a pre-existing problem. Change-Id: I1e2ecdbf0a3d4e2477cd4768a9b4a35a155e815b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151082 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx index 7f1a1db064d8..0650e48fe607 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler.cxx @@ -14,6 +14,8 @@ #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/style/BreakType.hpp> using namespace ::com::sun::star; @@ -57,6 +59,29 @@ CPPUNIT_TEST_FIXTURE(Test, testNestedFloatingTable) // was partly positioned outside the table cell, leading to overlapping text. CPPUNIT_ASSERT(bIsFollowingTextFlow); } + +CPPUNIT_TEST_FIXTURE(Test, testFloatingTableBreakBefore) +{ + // Given a 3 pages document: page break, then a multi-page floating table on pages 2 and 3: + // When laying out that document: + loadFromURL(u"floattable-break-before.docx"); + + // Then make sure the page break property is on the anchor of the floating table, otherwise it + // has no effect: + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xText(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParagraphs = xText->createEnumeration(); + xParagraphs->nextElement(); + xParagraphs->nextElement(); + uno::Reference<beans::XPropertySet> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); + style::BreakType eBreakType{}; + xParagraph->getPropertyValue("BreakType") >>= eBreakType; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 4 (style::BreakType_PAGE_BEFORE) + // - Actual : 0 (style::BreakType_NONE) + // i.e. the page break was lost. + CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, eBreakType); +} } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/qa/cppunittests/dmapper/data/floattable-break-before.docx b/writerfilter/qa/cppunittests/dmapper/data/floattable-break-before.docx new file mode 100644 index 000000000000..7fcfed4a637d Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/floattable-break-before.docx differ diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index eaddae615817..ac2f00a7d5a5 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -50,6 +50,7 @@ #include <comphelper/sequence.hxx> #include <comphelper/propertyvalue.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/style/BreakType.hpp> #include <boost/lexical_cast.hpp> #include <officecfg/Office/Writer.hxx> @@ -1541,6 +1542,15 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab // A non-zero left margin would move the table out of the frame, move the frame itself instead. xTableProperties->setPropertyValue("LeftMargin", uno::Any(sal_Int32(0))); + style::BreakType eBreakType{}; + xTableProperties->getPropertyValue("BreakType") >>= eBreakType; + if (eBreakType != style::BreakType_NONE) + { + // A break before the table was requested. Reset that break here, since the table + // will be at the start of the fly frame, not in the body frame. + xTableProperties->setPropertyValue("BreakType", uno::Any(style::BreakType_NONE)); + } + if (nestedTableLevel >= 2) { // Floating tables inside a table always stay inside the cell. @@ -1572,6 +1582,7 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab // Multi-page floating tables works if an outer/toplevel table is floating, but not // when an inner table would float. bool bToplevelSplitFly = nestedTableLevel <= 1; + uno::Reference<beans::XPropertySet> xFrameAnchor; if (xTextAppendAndConvert.is() && (!bTableStartsAtCellStart || bToplevelSplitFly)) { std::deque<css::uno::Any> aFramedRedlines = m_rDMapper_Impl.m_aStoredRedlines[StoredRedlines::FRAME]; @@ -1580,10 +1591,17 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel, bool bTab std::vector<OUString> redTable; BeforeConvertToTextFrame(aFramedRedlines, redPos, redLen, redCell, redTable); - xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, comphelper::containerToSequence(aFrameProperties)); + uno::Reference<text::XTextContent> xContent = xTextAppendAndConvert->convertToTextFrame(xStart, xEnd, comphelper::containerToSequence(aFrameProperties)); + xFrameAnchor.set(xContent->getAnchor(), uno::UNO_QUERY); AfterConvertToTextFrame(m_rDMapper_Impl, aFramedRedlines, redPos, redLen, redCell, redTable); } + + if (xFrameAnchor.is() && eBreakType != style::BreakType_NONE) + { + // A break before the table was requested. Restore that on the anchor. + xFrameAnchor->setPropertyValue("BreakType", uno::Any(eBreakType)); + } } } commit 2fe581d916b76d613742c983731fb4a10b4ee95f Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Tue Apr 18 10:34:47 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Apr 27 12:13:37 2023 +0200 fix bug in json_writer Ruler stores null-terminated strings in fixed length char arrays, so when creating a JSON a string might end earlier that it's size sugsests. Change-Id: Icdcaf35f9ce54c24dcd36368dc49bb688a2a65ce Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150542 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx index e7a0f55fd6c2..3111cac2f816 100644 --- a/tools/source/misc/json_writer.cxx +++ b/tools/source/misc/json_writer.cxx @@ -236,7 +236,8 @@ void JsonWriter::put(std::string_view pPropName, std::string_view rPropVal) ++mPos; // copy and perform escaping - for (size_t i = 0; i < rPropVal.size(); ++i) + bool bReachedEnd = false; + for (size_t i = 0; i < rPropVal.size() && !bReachedEnd; ++i) { char ch = rPropVal[i]; switch (ch) @@ -251,6 +252,9 @@ void JsonWriter::put(std::string_view pPropName, std::string_view rPropVal) case '\\': writeEscapedSequence(ch, mPos); break; + case 0: + bReachedEnd = true; + break; case '\xE2': // Special processing of U+2028 and U+2029 if (i + 2 < rPropVal.size() && rPropVal[i + 1] == '\x80' && (rPropVal[i + 2] == '\xA8' || rPropVal[i + 2] == '\xA9')) commit f62b1e17def7bc3881c7426229eabbaeb4cb5037 Author: Andrea Gelmini <andrea.gelm...@gelma.net> AuthorDate: Thu Apr 27 11:38:18 2023 +0200 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Thu Apr 27 11:39:33 2023 +0200 Fix typo Change-Id: I8ae43a371b925773e02e23631f18b74fd7bf366f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151092 Tested-by: Julien Nabet <serval2...@yahoo.fr> Reviewed-by: Julien Nabet <serval2...@yahoo.fr> diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index 301e2c83ba4f..00d8f2aabeb4 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1110,7 +1110,7 @@ void ScDPOutput::Output() std::vector<bool> vbSetBorder; vbSetBorder.resize( nTabEndRow - nDataStartRow + 1, false ); size_t nFieldColOffset = 0; - size_t nFieldIndentLevel = 0; // To calulate indent level for fields packed in a column. + size_t nFieldIndentLevel = 0; // To calculate indent level for fields packed in a column. size_t nNumRowFields = pRowFields.size(); for (size_t nField=0; nField<nNumRowFields; nField++) { commit 89afe2978500233dc7b58d39cc519ecb9c224e98 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Wed Apr 26 19:40:34 2023 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Thu Apr 27 11:12:52 2023 +0200 tdf#154818 - Find bar: remember and reuse last search string If there exists no last search string in the view options and there exists a search history, preselect the last search item. Change-Id: Ic6056e02eaf6c0ee7e266e47ba961dff11e9f9da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151072 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx index d43222fe4e32..1ae8a0b5c738 100644 --- a/svx/source/tbxctrls/tbunosearchcontrollers.cxx +++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx @@ -268,9 +268,12 @@ void FindTextFieldControl::SetTextToSelected_Impl() { css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem"); aUserItem >>= aString; - // prepopulate with last search word (fdo#84256) - m_xWidget->set_entry_text(aString); } + else if (get_count() > 0) + aString = m_xWidget->get_text(0); + + // prepopulate with last search word (fdo#84256) + m_xWidget->set_entry_text(aString); } } commit e4410284c9907c5c8938a4f54bdde22cf27bba56 Author: Seth Chaiklin <sdc.bla...@youmail.dk> AuthorDate: Thu Apr 27 10:13:00 2023 +0200 Commit: Gerrit Code Review <ger...@gerrit.libreoffice.org> CommitDate: Thu Apr 27 10:13:00 2023 +0200 Update git submodules * Update helpcontent2 from branch 'master' to a53384ca39c4423a4562583373eaaabc20e6763e - tdf#154717 improve notes about number format; simplify "refer to" also move "Chapter" format to correspond to position in UI. Change-Id: Idf76a27c42dc8fa1ba9ee36f80faf2ef36769b51 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/150512 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/helpcontent2 b/helpcontent2 index 6a79a8d4a5ca..a53384ca39c4 160000 --- a/helpcontent2 +++ b/helpcontent2 @@ -1 +1 @@ -Subproject commit 6a79a8d4a5ca9e76f0811ddc8fcf8d79b21728ac +Subproject commit a53384ca39c4423a4562583373eaaabc20e6763e commit 53279b8bc210485471f9550ebbc5ad09adefa4c0 Author: Dennis Francis <dennisfrancis...@gmail.com> AuthorDate: Thu Apr 27 12:36:49 2023 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Thu Apr 27 10:10:55 2023 +0200 add @since for COMPACT_LAYOUT Change-Id: I4b7f918e846ea1d220b9df2be5bc0b39d1f22f7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151086 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl index 4bbc233c674e..ae8cee9ee75c 100644 --- a/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl +++ b/offapi/com/sun/star/sheet/DataPilotFieldLayoutMode.idl @@ -68,6 +68,8 @@ constants DataPilotFieldLayoutMode the subtotals take up more than one row (manually selected, or because there are several data fields), they are always shown below the item's data, regardless of the setting.</p> + + @since LibreOffice 7.6 */ const long COMPACT_LAYOUT = 3; commit 0f83cbe27b95d991ce171a961950645a1ef67d7a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Apr 27 08:26:55 2023 +0200 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Apr 27 09:41:34 2023 +0200 Avoid temporary OUString creation Change-Id: I1cebcc2cbd36ed83d4898e222929c872f46c08d0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151028 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx index 7b17137363a7..27481e062590 100644 --- a/sfx2/source/dialog/StyleList.cxx +++ b/sfx2/source/dialog/StyleList.cxx @@ -100,7 +100,7 @@ Color ColorHash(std::u16string_view rString) static std::vector aSaturationArray{ 0.90, 0.75, 0.60 }; static std::vector aLightnessArray = aSaturationArray; - sal_uInt32 nStringHash = OUString(rString).hashCode(); + sal_uInt32 nStringHash = rtl_ustr_hashCode_WithLength(rString.data(), rString.length()); double nHue = nStringHash % 359; double nSaturation = aSaturationArray[nStringHash / 360 % aSaturationArray.size()]; commit 52acefd6024ec79f8333ba40eef83816eda3046f Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Apr 27 07:58:23 2023 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Thu Apr 27 09:14:08 2023 +0200 Revert "introduce sw::SpzFrameFormat ..." This reverts commit 09cdcb5f37bb4e42da7b28db6e757b9f2affed14. It broke at least CppunitTest_sw_uiwriter3 (<https://ci.libreoffice.org//job/lo_ubsan/2756/>), > /sw/source/core/undo/rolbck.cxx:938:46: runtime error: downcast of address 0x61300041fd00 which does not point to an object of type 'SwFlyFrameFormat' > 0x61300041fd00: note: object is of type 'SwDrawFrameFormat' > 00 00 00 00 70 83 cf 09 25 7f 00 00 00 83 47 00 30 61 00 00 40 e5 43 00 30 61 00 00 80 66 5d 00 > ^~~~~~~~~~~~~~~~~~~~~~~ > vptr for 'SwDrawFrameFormat' > #0 0x7f24fca9c5b9 in SwHistoryChangeFlyAnchor::SetInDoc(SwDoc*, bool) /sw/source/core/undo/rolbck.cxx:938:46 > #1 0x7f24fca880f3 in SwHistory::Rollback(SwDoc*, unsigned short) /sw/source/core/undo/rolbck.cxx:1208:15 > #2 0x7f24fcb47832 in SwUndoDelete::UndoImpl(sw::UndoRedoContext&) /sw/source/core/undo/undel.cxx:1031:33 > #3 0x7f24fcb703c2 in SwUndo::UndoWithContext(SfxUndoContext&) /sw/source/core/undo/undobj.cxx:225:5 > #4 0x7f2543b8b57c in SfxUndoManager::ImplUndo(SfxUndoContext*) /svl/source/undo/undo.cxx:712:22 > #5 0x7f2543b8c4f8 in SfxUndoManager::UndoWithContext(SfxUndoContext&) /svl/source/undo/undo.cxx:664:12 > #6 0x7f24fca6a074 in sw::UndoManager::impl_DoUndoRedo(sw::UndoManager::UndoOrRedoType, unsigned long) /sw/source/core/undo/docundo.cxx:696:32 > #7 0x7f24fca6b38f in sw::UndoManager::UndoWithOffset(unsigned long) /sw/source/core/undo/docundo.cxx:731:16 > #8 0x7f24fa830b18 in SwEditShell::Undo(unsigned short, unsigned short) /sw/source/core/edit/edundo.cxx:141:57 > #9 0x7f250088f448 in SwWrtShell::Do(SwWrtShell::DoType, unsigned short, unsigned short) /sw/source/uibase/wrtsh/wrtundo.cxx:45:26 > #10 0x7f24ff7f16e2 in SwBaseShell::ExecUndo(SfxRequest&) /sw/source/uibase/shells/basesh.cxx:651:27 > #11 0x7f24ff7eea14 in SfxStubSwBaseShellExecUndo(SfxShell*, SfxRequest&) /workdir/SdiTarget/sw/sdi/swslots.hxx:2203:1 > #12 0x7f2523fbc059 in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&, SfxRequest&, bool) /sfx2/source/control/dispatch.cxx:254:9 > #13 0x7f2523fd1ced in SfxDispatcher::Execute_(SfxShell&, SfxSlot const&, SfxRequest&, SfxCallMode) /sfx2/source/control/dispatch.cxx:753:9 > #14 0x7f2523f61333 in SfxBindings::Execute_Impl(SfxRequest&, SfxSlot const*, SfxShell*) /sfx2/source/control/bindings.cxx:1060:22 > #15 0x7f252437496b in SfxDispatchController_Impl::dispatch(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) /sfx2/source/control/unoctitm.cxx:688:53 > #16 0x7f2524377211 in SfxOfficeDispatch::dispatchWithNotification(com::sun::star::util::URL const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchResultListener> const&) /sfx2/source/control/unoctitm.cxx:266:16 > #17 0x7f24cad28dd6 in framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatch> const&, com::sun::star::util::URL const&, bool, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx:163:30 > #18 0x7f24cad27cb2 in framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx:120:16 > #19 0x7f24cad29684 in non-virtual thunk to framework::DispatchHelper::executeDispatch(com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, rtl::OUString const&, rtl::OUString const&, int, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /framework/source/services/dispatchhelper.cxx > #20 0x7f24e91d386d in unotest::MacrosTest::dispatchCommand(com::sun::star::uno::Reference<com::sun::star::lang::XComponent> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&) /unotest/source/cpp/macros_test.cxx:94:33 > #21 0x7f25319b2012 in testTdf132321::TestBody() /sw/qa/extras/uiwriter/uiwriter3.cxx:982:5 Change-Id: Ibeb181bc38cd6f88df76403cca8a15b45090633f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151027 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 7a1b2e0ee969..d9ff583fcdec 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -248,7 +248,7 @@ class SW_DLLPUBLIC SwDoc final std::unique_ptr<SwFrameFormats> mpFrameFormatTable; //< Format table std::unique_ptr<SwCharFormats> mpCharFormatTable; - std::unique_ptr<sw::FrameFormats<sw::SpzFrameFormat*>> mpSpzFrameFormatTable; + std::unique_ptr<SwFrameFormats> mpSpzFrameFormatTable; std::unique_ptr<SwSectionFormats> mpSectionFormatTable; std::unique_ptr<sw::TableFrameFormats> mpTableFrameFormatTable; //< For tables std::unique_ptr<SwTextFormatColls> mpTextFormatCollTable; //< FormatCollections @@ -754,8 +754,8 @@ public: SwCharFormats* GetCharFormats() { return mpCharFormatTable.get();} // LayoutFormats (frames, DrawObjects), sometimes const sometimes not - const sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); } - sw::FrameFormats<sw::SpzFrameFormat*>* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); } + const SwFrameFormats* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); } + SwFrameFormats* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); } const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat.get(); } SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat.get(); } diff --git a/sw/inc/frameformats.hxx b/sw/inc/frameformats.hxx index be3e5fd9ae77..97c86408e867 100644 --- a/sw/inc/frameformats.hxx +++ b/sw/inc/frameformats.hxx @@ -19,7 +19,6 @@ #pragma once #include "docary.hxx" -#include "frmfmt.hxx" #include "swtblfmt.hxx" #include <boost/multi_index_container.hpp> #include <boost/multi_index/composite_key.hpp> @@ -154,10 +153,6 @@ template <class value_type> class FrameFormats final : public SwFormatsBase friend class ::SwFrameFormat; public: - // getting from T* to T const* ... - typedef typename std::add_pointer< - typename std::add_const<typename std::remove_pointer<value_type>::type>::type>::type - const_value_type; typedef typename FrameFormatsContainer::size_type size_type; typedef typename FrameFormatsContainer::template index<ByPos>::type index_type; typedef typename index_type::iterator iterator; @@ -279,12 +274,7 @@ public: bool ContainsFormat(const value_type& rpFormat) const { return rpFormat->m_ffList == this; }; /// not so fast check that given format is still alive (i.e. contained here) - bool IsAlive(const_value_type pFrameFormat) const - { - auto pThisNonConst - = const_cast<typename std::remove_const<sw::FrameFormats<value_type>>::type*>(this); - return pThisNonConst->find(const_cast<value_type>(pFrameFormat)) != pThisNonConst->end(); - }; + bool IsAlive(value_type const* p) const { return find(*p) != end(); }; void DeleteAndDestroyAll(bool keepDefault = false) { @@ -324,10 +314,8 @@ public: }; }; typedef FrameFormats<::SwTableFormat*> TableFrameFormats; -typedef FrameFormats<sw::SpzFrameFormat*> SpzFrameFormats; } template class SW_DLLPUBLIC sw::FrameFormats<SwTableFormat*>; -template class SW_DLLPUBLIC sw::FrameFormats<sw::SpzFrameFormat*>; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index 309aa78de552..f5e44e03136c 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -23,27 +23,20 @@ #include <com/sun/star/text/PositionLayoutDir.hpp> #include <cppuhelper/weakref.hxx> #include <tools/gen.hxx> -namespace sw -{ - template<class T> class FrameFormats; - class SpzFrameFormat; -} #include "format.hxx" #include "hintids.hxx" #include "swdllapi.h" #include <list> #include "textboxhelper.hxx" +class SwFlyFrame; +class SwFlyDrawContact; +class SwAnchoredObject; class Graphic; -class IMapObject; class ImageMap; -class SdrObject; -class SwAnchoredObject; -class SwDrawFrameFormat; -class SwFlyDrawContact; -class SwFlyFrame; -class SwFlyFrameFormat; +class IMapObject; class SwRect; +class SdrObject; class SwRootFrame; class SwTableBox; @@ -61,7 +54,6 @@ namespace sw virtual ~FindSdrObjectHint() override; }; template<class T> class FrameFormats; - class SpzFrameFormat; } class SwFormatsBase; class SwFrameFormats; @@ -76,7 +68,6 @@ class SW_DLLPUBLIC SwFrameFormat friend class ::sw::DocumentLayoutManager; ///< Is allowed to call protected CTor. friend class SwFrameFormats; ///< Is allowed to update the list backref. friend class sw::FrameFormats<SwTableFormat*>; ///< Is allowed to update the list backref. - friend class sw::FrameFormats<sw::SpzFrameFormat*>; ///< Is allowed to update the list backref. friend class SwTextBoxHelper; friend class SwUndoFlyBase; ///< calls SetOtherTextBoxFormat @@ -199,25 +190,9 @@ public: virtual bool IsVisible() const; }; -namespace sw -{ - class SW_DLLPUBLIC SpzFrameFormat: public SwFrameFormat { - friend ::SwDrawFrameFormat; - friend ::SwFlyFrameFormat; - SpzFrameFormat( - SwAttrPool& rPool, - const OUString& rFormatName, - SwFrameFormat* pDerivedFrame, - sal_uInt16 nFormatWhich) - : SwFrameFormat(rPool, rFormatName, pDerivedFrame, nFormatWhich) - { - assert(nFormatWhich == RES_DRAWFRMFMT || nFormatWhich == RES_FLYFRMFMT); - }; - }; -} // The FlyFrame-Format -class SW_DLLPUBLIC SwFlyFrameFormat final : public sw::SpzFrameFormat +class SW_DLLPUBLIC SwFlyFrameFormat final : public SwFrameFormat { friend class SwDoc; OUString msTitle; @@ -405,7 +380,7 @@ namespace sw }; } -class SW_DLLPUBLIC SwDrawFrameFormat final : public sw::SpzFrameFormat +class SW_DLLPUBLIC SwDrawFrameFormat final : public SwFrameFormat { friend class SwDoc; @@ -421,12 +396,15 @@ class SW_DLLPUBLIC SwDrawFrameFormat final : public sw::SpzFrameFormat bool mbPosAttrSet; - SwDrawFrameFormat(SwAttrPool& rPool, const OUString& rFormatName, SwFrameFormat* pDerivedFrame) - : sw::SpzFrameFormat(rPool, rFormatName, pDerivedFrame, RES_DRAWFRMFMT), + SwDrawFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, + SwFrameFormat *pDrvdFrame ) + : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_DRAWFRMFMT ), m_pSdrObjectCached(nullptr), - meLayoutDir(SwFrameFormat::HORI_L2R), - mnPositionLayoutDir(css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor), - mbPosAttrSet(false) + meLayoutDir( SwFrameFormat::HORI_L2R ), + + mnPositionLayoutDir( css::text::PositionLayoutDir::PositionInLayoutDirOfAnchor ), + + mbPosAttrSet( false ) {} public: diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 2eef22d2b20e..ebf329342d8e 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -42,11 +42,6 @@ namespace com::sun::star::text { class XTextFrame; } -namespace sw -{ -template <class T> class FrameFormats; -class SpzFrameFormat; -} /** * A TextBox is a TextFrame, that is tied to a drawinglayer shape. @@ -170,7 +165,7 @@ public: static void getShapeWrapThrough(const SwFrameFormat* pTextBox, bool& rWrapThrough); /// Saves the current shape -> textbox links in a map, so they can be restored later. - static void saveLinks(const sw::FrameFormats<sw::SpzFrameFormat*>& rFormats, + static void saveLinks(const SwFrameFormats& rFormats, std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks); /// Undo the effect of saveLinks() + individual resetLink() calls. static void restoreLinks(std::set<ZSortFly>& rOld, std::vector<SwFrameFormat*>& rNew, diff --git a/sw/qa/core/attr/attr.cxx b/sw/qa/core/attr/attr.cxx index d123ed858b57..25d2a8025020 100644 --- a/sw/qa/core/attr/attr.cxx +++ b/sw/qa/core/attr/attr.cxx @@ -62,8 +62,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFormatFlySplit) RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; aMgr.InsertFlyFrame(eAnchor, aMgr.GetPos(), aMgr.GetSize()); SwDoc* pDoc = getSwDoc(); - sw::SpzFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); - sw::SpzFrameFormat* pFly = rFlys[0]; + SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFly = rFlys[0]; CPPUNIT_ASSERT(!pFly->GetAttrSet().GetFlySplit().GetValue()); SfxItemSet aSet(pFly->GetAttrSet()); diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index fc1ffc69e8d9..1597302a5f64 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -55,7 +55,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testMathInsertAnchorType) pShell->InsertObject(svt::EmbeddedObjectRef(), &aGlobalName); // Then the anchor type should be as-char. - sw::SpzFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size()); const SwFrameFormat& rFormat = *rFormats[0]; const SwFormatAnchor& rAnchor = rFormat.GetAnchor(); @@ -72,7 +72,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle) // Check the writing direction of the only TextFrame in the document. createSwDoc("textbox-textrotateangle.odt"); SwDoc* pDoc = getSwDoc(); - sw::SpzFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFrameFormats.size()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFrameFormats[0]->Which()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFrameFormats[1]->Which()); @@ -132,9 +132,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextBoxZOrder) { createSwDoc("textbox-zorder.docx"); SwDoc* pDoc = getSwDoc(); - sw::SpzFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rFormats.size()); - const sw::SpzFrameFormat* pEllipse = rFormats[2]; + const SwFrameFormat* pEllipse = rFormats[2]; const SdrObject* pEllipseShape = pEllipse->FindRealSdrObject(); // Make sure we test the right shape. CPPUNIT_ASSERT_EQUAL(OUString("Shape3"), pEllipseShape->GetName()); @@ -291,9 +291,10 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testCopyBookmarks) // Also, when checking the # of non-copy images in the resulting doc model: nActual = 0; - for (auto pSpz : *pDoc->GetSpzFrameFormats()) + SwFrameFormats& rFrameFormats = *pDoc->GetSpzFrameFormats(); + for (size_t i = 0; i < rFrameFormats.size(); ++i) { - if (pSpz->GetName().indexOf("Copy") == -1) + if (rFrameFormats[i]->GetName().indexOf("Copy") == -1) { ++nActual; } diff --git a/sw/qa/core/draw/draw.cxx b/sw/qa/core/draw/draw.cxx index b77a4ea65d94..17bedbdbab9c 100644 --- a/sw/qa/core/draw/draw.cxx +++ b/sw/qa/core/draw/draw.cxx @@ -64,7 +64,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreDrawTest, testTextboxUndoOrdNum) createSwDoc("textbox-undo-ordnum.docx"); SwDoc* pDoc = getSwDoc(); SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); - const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); // Test the state before del + undo. for (const auto& pFormat : rFormats) { diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 1ad1443dd392..f7e6992bf014 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -77,8 +77,8 @@ void Test::Create1x2SplitFly() pWrtShell->EndAllAction(); // Allow the text frame to split: pWrtShell->StartAllAction(); - auto& rFlys = *pDoc->GetSpzFrameFormats(); - auto pFly = rFlys[0]; + SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFly = rFlys[0]; SwAttrSet aSet(pFly->GetAttrSet()); aSet.Put(SwFormatFlySplit(true)); pDoc->SetAttr(aSet, *pFly); diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx index f99cc3dd54dd..e0526bdbb361 100644 --- a/sw/qa/core/txtnode/txtnode.cxx +++ b/sw/qa/core/txtnode/txtnode.cxx @@ -74,7 +74,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testTextBoxCopyAnchor) pWrtShell->SttEndDoc(/*bStart=*/false); pWrtShell->Paste(aClipboard); - const auto& rFormats = *pShell->GetDoc()->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pShell->GetDoc()->GetSpzFrameFormats(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 4 // - Actual : 6 @@ -176,7 +176,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testFlyAnchorUndo) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDocShell* pShell = pTextDoc->GetDocShell(); SwDoc* pDoc = pShell->GetDoc(); - const auto& rSpz = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rSpz = *pDoc->GetSpzFrameFormats(); sal_Int32 nExpected = rSpz[0]->GetAnchor().GetAnchorContentOffset(); // When deleting that last character and undoing it: diff --git a/sw/qa/core/undo/undo.cxx b/sw/qa/core/undo/undo.cxx index 221f2ba4ece7..21543416dae8 100644 --- a/sw/qa/core/undo/undo.cxx +++ b/sw/qa/core/undo/undo.cxx @@ -66,7 +66,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUndoTest, testTextboxCutUndo) selectShape(1); rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell); pTransfer->Cut(); - auto& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rSpzFrameFormats.size()); pWrtShell->Undo(); diff --git a/sw/qa/core/view/view.cxx b/sw/qa/core/view/view.cxx index 576095c7f4cc..a3fd1863031e 100644 --- a/sw/qa/core/view/view.cxx +++ b/sw/qa/core/view/view.cxx @@ -49,11 +49,13 @@ CPPUNIT_TEST_FIXTURE(Test, testUpdateOleObjectPreviews) pWrtShell->UpdateOleObjectPreviews(); // Then make sure that the working preview of those objects are not lost: - const auto pFormats = pDoc->GetSpzFrameFormats(); + const SwFrameFormats* pFormats = pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(pFormats); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pFormats->size()); - for (auto pFormat : *pFormats) + for (size_t i = 0; i < pFormats->size(); ++i) { + SwFrameFormat* pFormat = (*pFormats)[i]; + const SwNodeIndex* pNodeIndex = pFormat->GetContent().GetContentIdx(); CPPUNIT_ASSERT(pNodeIndex); SwNode* pNode = pDoc->GetNodes()[pNodeIndex->GetIndex() + 1]; diff --git a/sw/qa/extras/htmlimport/htmlimport.cxx b/sw/qa/extras/htmlimport/htmlimport.cxx index 34900529ada9..93c6598225b1 100644 --- a/sw/qa/extras/htmlimport/htmlimport.cxx +++ b/sw/qa/extras/htmlimport/htmlimport.cxx @@ -402,7 +402,7 @@ CPPUNIT_TEST_FIXTURE(HtmlImportTest, testTdf122789) SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rFormats.size()); // This failed, the image had an absolute size, not a relative one. CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>(70), rFormats[0]->GetAttrSet().GetFrameSize().GetWidthPercent()); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index a0dd296e5e32..d69b53fa924c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1103,8 +1103,8 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf115094v3) createSwDoc("tdf115094v3.docx"); { SwDoc* pDoc = getSwDoc(); - auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); - auto pFormat = rSpzFormats[0]; + SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFormat = rSpzFormats[0]; // Without the fix, this has failed with: // - Expected: 1991 // - Actual : 1883 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 491626ff7812..a1610c35dbbb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -324,7 +324,7 @@ DECLARE_OOXMLEXPORT_TEST(testBtlrShape, "btlr-textbox.docx") SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); - const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_DRAWFRMFMT), rFormats[0]->Which()); CPPUNIT_ASSERT_EQUAL(o3tl::narrowing<sal_uInt16>(RES_FLYFRMFMT), rFormats[1]->Which()); diff --git a/sw/qa/extras/rtfexport/rtfexport4.cxx b/sw/qa/extras/rtfexport/rtfexport4.cxx index 0213d0b893b7..3ae9fa470000 100644 --- a/sw/qa/extras/rtfexport/rtfexport4.cxx +++ b/sw/qa/extras/rtfexport/rtfexport4.cxx @@ -243,7 +243,7 @@ DECLARE_RTFEXPORT_TEST(testAnchoredAtSamePosition, "anchor.fodt") CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getParagraph(1)->getString()); - auto& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rFlys(*pDoc->GetSpzFrameFormats()); if (isExported()) { // 2, not 3: the form control becomes a field on export... CPPUNIT_ASSERT_EQUAL(size_t(2), rFlys.size()); diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 1833b1220dbd..492de89912bc 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -753,7 +753,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf137245) CPPUNIT_ASSERT(pFly != nullptr); } - const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rFormats.size()); // move cursor back to body @@ -2692,12 +2692,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf122942) pWrtShell->EndCreate(SdrCreateCmd::ForceEnd); // Make sure that the shape is inserted. - const auto& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size()); reload("writer8", "tdf122942.odt"); pDoc = getSwDoc(); - const auto& rFormats2 = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFormats2 = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats2.size()); // Make sure the top of the inserted shape does not move outside the existing shape, even after diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index b7a9a08d4316..a0356dfec4e5 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1459,10 +1459,10 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testShapePageMove) { &aXItem, &aYItem }); // Check if the shape anchor was moved to the 2nd page as well. - auto pShapeFormats = pDoc->GetSpzFrameFormats(); + SwFrameFormats* pShapeFormats = pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(!pShapeFormats->empty()); auto it = pShapeFormats->begin(); - auto pShapeFormat = *it; + SwFrameFormat* pShapeFormat = *it; const SwPosition* pAnchor = pShapeFormat->GetAnchor().GetContentAnchor(); CPPUNIT_ASSERT(pAnchor); @@ -2798,7 +2798,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf128603) rUndoManager.Undo(); // Make sure the content indexes still match. - const auto& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rSpzFrameFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(6), rSpzFrameFormats.size()); const SwNodeIndex* pIndex4 = rSpzFrameFormats[4]->GetContent().GetContentIdx(); CPPUNIT_ASSERT(pIndex4); diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx b/sw/qa/extras/uiwriter/uiwriter8.cxx index 81a6d9e25fc2..65a1352dc79b 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -1072,7 +1072,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf130805) createSwDoc("tdf130805.odt"); SwDoc* pDoc = getSwDoc(); - const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); @@ -1097,9 +1097,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf107893) SwDoc* pDoc = getSwDoc(); //Get the format of the shape - const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); - auto pShape = rFrmFormats.front(); + SwFrameFormat* pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); //Add a textbox @@ -1150,9 +1150,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, TestTextBoxCrashAfterLineDel) SwDoc* pDoc = getSwDoc(); // Get the format of the shape - const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); - auto pShape = rFrmFormats.front(); + SwFrameFormat* pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); // Add a textbox @@ -1974,7 +1974,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, AtPageTextBoxCrash) SwDoc* pDoc = getSwDoc(); // Get the format of the shape - const auto& rFrmFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormats& rFrmFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(rFrmFormats.size() >= size_t(o3tl::make_unsigned(1))); auto pShape = rFrmFormats.front(); CPPUNIT_ASSERT(pShape); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index d248c6ce6b26..f4274a629d39 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -689,10 +689,10 @@ DECLARE_WW8EXPORT_TEST(testTdf112535, "tdf112535.doc") SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); CPPUNIT_ASSERT(pDoc->GetSpzFrameFormats()); - auto& rFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); CPPUNIT_ASSERT(!rFormats.empty()); - const auto pFormat = rFormats[0]; + const SwFrameFormat* pFormat = rFormats[0]; CPPUNIT_ASSERT(pFormat); // Without the accompanying fix in place, this test would have failed: auto-contour was enabled diff --git a/sw/qa/filter/html/html.cxx b/sw/qa/filter/html/html.cxx index 523bc49a4358..6cd714bbdd48 100644 --- a/sw/qa/filter/html/html.cxx +++ b/sw/qa/filter/html/html.cxx @@ -65,8 +65,8 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspect) // Then make sure that the aspect ratio of the image is kept: auto pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDoc* pDoc = pTextDocument->GetDocShell()->GetDoc(); - const auto& rFormats = *pDoc->GetSpzFrameFormats(); - const auto pFormat = rFormats[0]; + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormat* pFormat = rFormats[0]; const SwFormatFrameSize& rSize = pFormat->GetFrameSize(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 255 @@ -86,8 +86,8 @@ CPPUNIT_TEST_FIXTURE(Test, testRelativeKeepAspectImage) // Then make sure that the aspect ratio of the image is kept: auto pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); SwDoc* pDoc = pTextDocument->GetDocShell()->GetDoc(); - const auto& rFormats = *pDoc->GetSpzFrameFormats(); - const auto pFormat = rFormats[0]; + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormat* pFormat = rFormats[0]; const SwFormatFrameSize& rSize = pFormat->GetFrameSize(); // Without the accompanying fix in place, this test would have failed with: // - Expected: 255 diff --git a/sw/qa/filter/ww8/ww8.cxx b/sw/qa/filter/ww8/ww8.cxx index b732a37eff40..a83bd12431df 100644 --- a/sw/qa/filter/ww8/ww8.cxx +++ b/sw/qa/filter/ww8/ww8.cxx @@ -214,8 +214,8 @@ CPPUNIT_TEST_FIXTURE(Test, testDocxFloatingTableExport) pWrtShell->StartAllAction(); aMgr.InsertFlyFrame(RndStdIds::FLY_AT_PARA, aMgr.GetPos(), aMgr.GetSize()); // Mark it as a floating table: - auto& rFlys = *pDoc->GetSpzFrameFormats(); - auto pFly = rFlys[0]; + SwFrameFormats& rFlys = *pDoc->GetSpzFrameFormats(); + SwFrameFormat* pFly = rFlys[0]; SwAttrSet aSet(pFly->GetAttrSet()); aSet.Put(SwFormatFlySplit(true)); pDoc->SetAttr(aSet, *pFly); diff --git a/sw/qa/uibase/docvw/docvw.cxx b/sw/qa/uibase/docvw/docvw.cxx index 280a0459109e..677a5abd2a54 100644 --- a/sw/qa/uibase/docvw/docvw.cxx +++ b/sw/qa/uibase/docvw/docvw.cxx @@ -48,7 +48,7 @@ CPPUNIT_TEST_FIXTURE(Test, testShiftClickOnImage) pWrtShell->SttEndDoc(/*bStt=*/false); // When shift-clicking on that fly frame: - auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); auto pFrameFormat = dynamic_cast<SwFlyFrameFormat*>(rSpzFormats[0]); CPPUNIT_ASSERT(pFrameFormat); SwFlyFrame* pFlyFrame = pFrameFormat->GetFrame(); @@ -163,7 +163,7 @@ CPPUNIT_TEST_FIXTURE(Test, testShiftDoubleClickOnImage) xRegistration->registerDispatchProviderInterceptor(pInterceptor); // When shift-double-clicking on that fly frame: - auto& rSpzFormats = *pDoc->GetSpzFrameFormats(); + SwFrameFormats& rSpzFormats = *pDoc->GetSpzFrameFormats(); auto pFrameFormat = dynamic_cast<SwFlyFrameFormat*>(rSpzFormats[0]); CPPUNIT_ASSERT(pFrameFormat); SwFlyFrame* pFlyFrame = pFrameFormat->GetFrame(); diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx index 6ad35e07466a..b9f03d42d5ee 100644 --- a/sw/qa/uibase/uno/uno.cxx +++ b/sw/qa/uibase/uno/uno.cxx @@ -149,8 +149,8 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testCreateTextRangeByPixelPositionGraphic) = xController->createTextRangeByPixelPosition(aPoint); // Then make sure that the anchor of the image is returned: - const auto& rFormats = *pDoc->GetSpzFrameFormats(); - const auto pFormat = rFormats[0]; + const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats(); + const SwFrameFormat* pFormat = rFormats[0]; SwPosition aAnchorPos(*pFormat->GetAnchor().GetContentAnchor()); auto pTextRange = dynamic_cast<SwXTextRange*>(xTextRange.get()); SwPaM aPaM(pDoc->GetNodes()); diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 7a1b94af15ef..c5c0c741f5dd 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -2746,9 +2746,10 @@ bool SwCursorShell::SelectNxtPrvHyperlink( bool bNext ) // then check all the Flys with a URL or image map { - for(sw::SpzFrameFormat* pSpz: *GetDoc()->GetSpzFrameFormats()) + const SwFrameFormats* pFormats = GetDoc()->GetSpzFrameFormats(); + for( SwFrameFormats::size_type n = 0, nEnd = pFormats->size(); n < nEnd; ++n ) { - auto pFormat = static_cast<SwFlyFrameFormat*>(pSpz); + SwFlyFrameFormat* pFormat = static_cast<SwFlyFrameFormat*>((*pFormats)[ n ]); const SwFormatURL& rURLItem = pFormat->GetURL(); if( rURLItem.GetMap() || !rURLItem.GetURL().isEmpty() ) { diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx index d87e0c2f2374..dd71aba69cc9 100644 --- a/sw/source/core/doc/CntntIdxStore.cxx +++ b/sw/source/core/doc/CntntIdxStore.cxx @@ -370,12 +370,12 @@ void ContentIdxStoreImpl::SaveFlys(SwDoc& rDoc, SwNodeOffset nNode, sal_Int32 nC void ContentIdxStoreImpl::RestoreFlys(SwDoc& rDoc, updater_t const & rUpdater, bool bAuto, bool bAtStart) { - sw::SpzFrameFormats* pSpz = rDoc.GetSpzFrameFormats(); + SwFrameFormats* pSpz = rDoc.GetSpzFrameFormats(); for (const MarkEntry& aEntry : m_aFlyEntries) { if(!aEntry.m_bOther) { - sw::SpzFrameFormat* pFrameFormat = (*pSpz)[ aEntry.m_nIdx ]; + SwFrameFormat *pFrameFormat = (*pSpz)[ aEntry.m_nIdx ]; const SwFormatAnchor& rFlyAnchor = pFrameFormat->GetAnchor(); if( rFlyAnchor.GetContentAnchor() ) { diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 3a158e26a9a1..3d86d7ffec8f 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -101,9 +101,11 @@ namespace bool lcl_ChkFlyFly( SwDoc& rDoc, SwNodeOffset nSttNd, SwNodeOffset nEndNd, SwNodeOffset nInsNd ) { + const SwFrameFormats& rFrameFormatTable = *rDoc.GetSpzFrameFormats(); - for(sw::SpzFrameFormat* pFormat: *rDoc.GetSpzFrameFormats()) + for( size_t n = 0; n < rFrameFormatTable.size(); ++n ) { + SwFrameFormat const*const pFormat = rFrameFormatTable[n]; SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && @@ -2308,7 +2310,7 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam ) // If there are FlyFrames left, delete these too for( size_t n = 0; n < m_rDoc.GetSpzFrameFormats()->size(); ++n ) { - sw::SpzFrameFormat* pFly = (*m_rDoc.GetSpzFrameFormats())[n]; + SwFrameFormat* pFly = (*m_rDoc.GetSpzFrameFormats())[n]; const SwFormatAnchor* pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 6959b7c7ba3a..e0366bdd3a0b 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -248,19 +248,20 @@ void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat ) pContentIdx = pFormat->GetContent().GetContentIdx(); if (pContentIdx) { - sw::SpzFrameFormats* pSpzs = pFormat->GetDoc()->GetSpzFrameFormats(); - if ( pSpzs ) + const SwFrameFormats* pTable = pFormat->GetDoc()->GetSpzFrameFormats(); + if ( pTable ) { std::vector<SwFrameFormat*> aToDeleteFrameFormats; const SwNodeOffset nNodeIdxOfFlyFormat( pContentIdx->GetIndex() ); - for(sw::SpzFrameFormat* pSpz: *pSpzs) + for ( size_t i = 0; i < pTable->size(); ++i ) { - const SwFormatAnchor &rAnch = pSpz->GetAnchor(); + SwFrameFormat* pTmpFormat = (*pTable)[i]; + const SwFormatAnchor &rAnch = pTmpFormat->GetAnchor(); if ( rAnch.GetAnchorId() == RndStdIds::FLY_AT_FLY && rAnch.GetAnchorNode()->GetIndex() == nNodeIdxOfFlyFormat ) { - aToDeleteFrameFormats.push_back(pSpz); + aToDeleteFrameFormats.push_back( pTmpFormat ); } } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 1c8e5327d4aa..8b1f18348796 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -407,14 +407,15 @@ static OUString lcl_AnchoredFrames(const SwNode & rNode) OUStringBuffer aResult("["); const SwDoc& rDoc = rNode.GetDoc(); - const sw::SpzFrameFormats* pSpzs = rDoc.GetSpzFrameFormats(); + const SwFrameFormats * pFrameFormats = rDoc.GetSpzFrameFormats(); - if (pSpzs) + if (pFrameFormats) { bool bFirst = true; - for(const sw::SpzFrameFormat* pSpz: *pSpzs) + for (SwFrameFormats::const_iterator i(pFrameFormats->begin()); + i != pFrameFormats->end(); ++i) { - const SwFormatAnchor& rAnchor = pSpz->GetAnchor(); + const SwFormatAnchor & rAnchor = (*i)->GetAnchor(); const SwNode * pPos = rAnchor.GetAnchorNode(); if (pPos && *pPos == rNode) @@ -422,8 +423,8 @@ static OUString lcl_AnchoredFrames(const SwNode & rNode) if (! bFirst) aResult.append(", "); - if (pSpz) - aResult.append(lcl_dbg_out(*pSpz)); + if (*i) + aResult.append(lcl_dbg_out(**i)); bFirst = false; } } diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index c28a15f12bf5..6bf54c6b6e5a 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -157,10 +157,10 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall case EVENT_OBJECT_URLITEM: case EVENT_OBJECT_IMAGE: { - const auto pSpz = static_cast<const sw::SpzFrameFormat*>(rCallEvent.PTR.pFormat); + const SwFrameFormat* pFormat = rCallEvent.PTR.pFormat; if( bCheckPtr ) { - if (GetSpzFrameFormats()->IsAlive(pSpz)) + if (GetSpzFrameFormats()->IsAlive(pFormat)) bCheckPtr = false; // misuse as a flag else // this shouldn't be possible now that SwCallMouseEvent @@ -168,7 +168,7 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall assert(false); } if( !bCheckPtr ) - pTable = &pSpz->GetMacro().GetMacroTable(); + pTable = &pFormat->GetMacro().GetMacroTable(); } break; @@ -177,10 +177,10 @@ sal_uInt16 SwDoc::CallEvent( SvMacroItemId nEvent, const SwCallMouseEvent& rCall const IMapObject* pIMapObj = rCallEvent.PTR.IMAP.pIMapObj; if( bCheckPtr ) { - const auto pSpz = static_cast<const sw::SpzFrameFormat*>(rCallEvent.PTR.IMAP.pFormat); - if (GetSpzFrameFormats()->IsAlive(pSpz)) + const SwFrameFormat* pFormat = rCallEvent.PTR.IMAP.pFormat; + if (GetSpzFrameFormats()->IsAlive(pFormat)) { - const ImageMap* pIMap = pSpz->GetURL().GetMap(); + const ImageMap* pIMap = pFormat->GetURL().GetMap(); if (pIMap) { for( size_t nPos = pIMap->GetIMapObjectCount(); nPos; ) diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 2941112bc5d8..1779ec998300 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1795,14 +1795,14 @@ namespace std::make_shared<CompareMainText>(rDestDoc, true)); //if we have the same number of frames then try to compare within them - const sw::SpzFrameFormats* pSrcFrameFormats = rSrcDoc.GetSpzFrameFormats(); - const sw::SpzFrameFormats* pDestFrameFormats = rDestDoc.GetSpzFrameFormats(); + const SwFrameFormats *pSrcFrameFormats = rSrcDoc.GetSpzFrameFormats(); + const SwFrameFormats *pDestFrameFormats = rDestDoc.GetSpzFrameFormats(); if (pSrcFrameFormats->size() == pDestFrameFormats->size()) { - for(sw::FrameFormats<sw::SpzFrameFormat*>::size_type i = 0; i < pSrcFrameFormats->size(); ++i) + for (size_t i = 0; i < pSrcFrameFormats->size(); ++i) { - const sw::SpzFrameFormat& rSrcFormat = *(*pSrcFrameFormats)[i]; - const sw::SpzFrameFormat& rDestFormat = *(*pDestFrameFormats)[i]; + const SwFrameFormat& rSrcFormat = *(*pSrcFrameFormats)[i]; + const SwFrameFormat& rDestFormat = *(*pDestFrameFormats)[i]; const SwNodeIndex* pSrcIdx = rSrcFormat.GetContent().GetContentIdx(); const SwNodeIndex* pDestIdx = rDestFormat.GetContent().GetContentIdx(); if (!pSrcIdx && !pDestIdx) diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 3994f2af8aac..a93000b679fc 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -93,7 +93,7 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& rStartPos, } aAnchor.SetAnchor( &aPos ); - pFormat->GetDoc()->GetSpzFrameFormats()->push_back(static_cast<sw::SpzFrameFormat*>(pFormat)); + pFormat->GetDoc()->GetSpzFrameFormats()->push_back( pFormat ); // SetFormatAttr should call Modify() and add it to the node pFormat->SetFormatAttr( aAnchor ); SwContentNode* pCNd = aPos.GetNode().GetContentNode(); @@ -105,11 +105,11 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& rStartPos, void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) { - sw::SpzFrameFormats& rSpzs = *rRg.aStart.GetNode().GetDoc().GetSpzFrameFormats(); - for(sw::FrameFormats<sw::SpzFrameFormat*>::size_type n = 0; n < rSpzs.size(); ++n ) + SwFrameFormats& rFormats = *rRg.aStart.GetNode().GetDoc().GetSpzFrameFormats(); + for( SwFrameFormats::size_type n = 0; n < rFormats.size(); ++n ) { - auto pSpz = rSpzs[n]; - SwFormatAnchor const*const pAnchor = &pSpz->GetAnchor(); + SwFrameFormat *const pFormat = rFormats[n]; + SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); if (pAnchorNode && ((RndStdIds::FLY_AT_PARA == pAnchor->GetAnchorId()) || @@ -120,14 +120,14 @@ void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) (RndStdIds::FLY_AT_CHAR == pAnchor->GetAnchorId()) ? pAnchor->GetAnchorContentOffset() : 0, - pSpz, false ); + pFormat, false ); rArr.push_back( aSave ); - pSpz->DelFrames(); + pFormat->DelFrames(); // set a dummy anchor position to maintain anchoring invariants - SwFormatAnchor aAnchor( pSpz->GetAnchor() ); + SwFormatAnchor aAnchor( pFormat->GetAnchor() ); aAnchor.SetAnchor(nullptr); - pSpz->SetFormatAttr(aAnchor); - rSpzs.erase( rSpzs.begin() + n-- ); + pFormat->SetFormatAttr(aAnchor); + rFormats.erase( rFormats.begin() + n-- ); } } sw::CheckAnchoredFlyConsistency(rRg.aStart.GetNode().GetDoc()); @@ -136,8 +136,8 @@ void SaveFlyInRange( const SwNodeRange& rRg, SaveFlyArr& rArr ) void SaveFlyInRange( const SwPaM& rPam, const SwPosition& rInsPos, SaveFlyArr& rArr, bool bMoveAllFlys, SwHistory *const pHistory) { - sw::SpzFrameFormats& rFormats = *rPam.GetPoint()->GetNode().GetDoc().GetSpzFrameFormats(); - sw::SpzFrameFormat* pFormat; + SwFrameFormats& rFormats = *rPam.GetPoint()->GetNode().GetDoc().GetSpzFrameFormats(); + SwFrameFormat* pFormat; const SwFormatAnchor* pAnchor; const SwPosition* pPos = rPam.Start(); @@ -220,10 +220,10 @@ void DelFlyInRange( SwNode& rMkNd, SwPosition const& rEnd = mark <= point ? point : mark; SwDoc& rDoc = rMkNd.GetDoc(); - sw::SpzFrameFormats& rTable = *rDoc.GetSpzFrameFormats(); + SwFrameFormats& rTable = *rDoc.GetSpzFrameFormats(); for ( auto i = rTable.size(); i; ) { - sw::SpzFrameFormat* pFormat = rTable[--i]; + SwFrameFormat *pFormat = rTable[--i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); SwPosition const*const pAPos = rAnch.GetContentAnchor(); if (pAPos && @@ -248,7 +248,7 @@ void DelFlyInRange( SwNode& rMkNd, if (i > rTable.size()) i = rTable.size(); else if (i == rTable.size() || pFormat != rTable[i]) - i = std::distance(rTable.begin(), rTable.find(pFormat)); + i = std::distance(rTable.begin(), rTable.find( pFormat )); } rDoc.getIDocumentLayoutAccess().DelLayoutFormat( pFormat ); diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 1d425e62f73d..998f123ee6c0 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -67,11 +67,15 @@ using namespace ::com::sun::star; size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const { + const SwFrameFormats& rFormats = *GetSpzFrameFormats(); + const size_t nSize = rFormats.size(); size_t nCount = 0; const SwNodeIndex* pIdx; - for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) + for ( size_t i = 0; i < nSize; ++i) { + const SwFrameFormat* pFlyFormat = rFormats[ i ]; + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; @@ -110,12 +114,16 @@ size_t SwDoc::GetFlyCount( FlyCntType eType, bool bIgnoreTextBoxes ) const /// @attention If you change this, also update SwXFrameEnumeration in unocoll. SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes ) { + SwFrameFormats& rFormats = *GetSpzFrameFormats(); SwFrameFormat* pRetFormat = nullptr; + const size_t nSize = rFormats.size(); const SwNodeIndex* pIdx; size_t nCount = 0; - for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) + for( size_t i = 0; !pRetFormat && i < nSize; ++i ) { + SwFrameFormat* pFlyFormat = rFormats[ i ]; + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) continue; @@ -151,11 +159,16 @@ SwFrameFormat* SwDoc::GetFlyNum( size_t nIdx, FlyCntType eType, bool bIgnoreText std::vector<SwFrameFormat const*> SwDoc::GetFlyFrameFormats( FlyCntType const eType, bool const bIgnoreTextBoxes) { + SwFrameFormats& rFormats = *GetSpzFrameFormats(); + const size_t nSize = rFormats.size(); + std::vector<SwFrameFormat const*> ret; - ret.reserve(GetSpzFrameFormats()->size()); + ret.reserve(nSize); - for(sw::SpzFrameFormat* pFlyFormat: *GetSpzFrameFormats()) + for (size_t i = 0; i < nSize; ++i) { + SwFrameFormat const*const pFlyFormat = rFormats[ i ]; + if (bIgnoreTextBoxes && SwTextBoxHelper::isTextBox(pFlyFormat, RES_FLYFRMFMT)) { continue; @@ -1012,7 +1025,7 @@ SwChainRet SwDoc::Chainable( const SwFrameFormat &rSource, const SwFrameFormat & return SwChainRet::NOT_EMPTY; } - for(sw::SpzFrameFormat* pSpzFrameFm: *GetSpzFrameFormats()) + for( auto pSpzFrameFm : *GetSpzFrameFormats() ) { const SwFormatAnchor& rAnchor = pSpzFrameFm->GetAnchor(); // #i20622# - to-frame anchored objects are allowed. diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index a0111f537469..aa737661d6dc 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -723,14 +723,13 @@ void SwDoc::DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast ) } else { - auto pSpz = static_cast<sw::SpzFrameFormat*>(pFormat); - if(GetSpzFrameFormats()->ContainsFormat(pSpz)) + bool contains = GetSpzFrameFormats()->ContainsFormat(*pFormat); + OSL_ENSURE( contains, "FrameFormat not found." ); + if( contains ) { - GetSpzFrameFormats()->erase(pSpz); - delete pSpz; + GetSpzFrameFormats()->erase( pFormat ); + delete pFormat; } - else - SAL_WARN("sw", "FrameFormat not found."); } } } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index c56eae683a9c..94229dbc968f 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -501,7 +501,7 @@ SwPosFlyFrames SwDoc::GetAllFlyFormats( const SwPaM* pCmpRange, bool bDrawAlso, SwPosFlyFrames aRetval; // collect all anchored somehow to paragraphs - for(sw::SpzFrameFormat* pFly: *GetSpzFrameFormats()) + for( auto pFly : *GetSpzFrameFormats() ) { bool bDrawFormat = bDrawAlso && RES_DRAWFRMFMT == pFly->Which(); bool bFlyFormat = RES_FLYFRMFMT == pFly->Which(); @@ -1350,11 +1350,14 @@ static OUString lcl_GetUniqueFlyName(const SwDoc& rDoc, TranslateId pDefStrId, s OUString aName(SwResId(pDefStrId)); sal_Int32 nNmLen = aName.getLength(); + const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); + std::vector<unsigned int> aUsedNums; - aUsedNums.reserve(rDoc.GetSpzFrameFormats()->size()); + aUsedNums.reserve(rFormats.size()); - for(sw::SpzFrameFormat* pFlyFormat: *rDoc.GetSpzFrameFormats()) + for( SwFrameFormats::size_type n = 0; n < rFormats.size(); ++n ) { + const SwFrameFormat* pFlyFormat = rFormats[ n ]; if (eType != pFlyFormat->Which()) continue; if (eType == RES_DRAWFRMFMT) @@ -1574,7 +1577,7 @@ bool SwDoc::IsInHeaderFooter( const SwNode& rIdx ) const // get up by using the Anchor #if OSL_DEBUG_LEVEL > 0 std::vector<const SwFrameFormat*> checkFormats; - for(sw::SpzFrameFormat* pFormat: *GetSpzFrameFormats()) + for( auto pFormat : *GetSpzFrameFormats() ) { const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if( pIdx && pFlyNd == &pIdx->GetNode() ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index bfc8c71dfe48..5884616e9ee9 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -234,7 +234,7 @@ SwDoc::SwDoc() mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ), mpFrameFormatTable( new SwFrameFormats() ), mpCharFormatTable( new SwCharFormats ), - mpSpzFrameFormatTable( new sw::FrameFormats<sw::SpzFrameFormat*>() ), + mpSpzFrameFormatTable( new SwFrameFormats() ), mpSectionFormatTable( new SwSectionFormats ), mpTableFrameFormatTable( new sw::TableFrameFormats() ), mpTextFormatCollTable( new SwTextFormatColls() ), @@ -1291,7 +1291,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu } // finally copy page bound frames - for(sw::SpzFrameFormat* pCpyFormat: *rSource.GetSpzFrameFormats()) + for ( auto pCpyFormat : *rSource.GetSpzFrameFormats() ) { const SwFrameFormat& rCpyFormat = *pCpyFormat; SwFormatAnchor aAnchor( rCpyFormat.GetAnchor() ); diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index d22ab372e323..3601c119bbb3 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -286,7 +286,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) auto [pStart, pEnd] = rPaM.StartEnd(); // SwPosition* // Set index to the Selection's start - for(sw::SpzFrameFormat* pFormat: *GetSpzFrameFormats()) + for ( const auto *pFormat : *GetSpzFrameFormats() ) { SwFormatAnchor const*const pAnchor = &pFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index 0b11ea6c80d2..c39d9c387a3c 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -540,7 +540,7 @@ static void lcl_CpyBox( const SwTable& rCpyTable, const SwTableBox* pCpyBox, } // If we still have FlyFrames hanging around, delete them too - for(sw::SpzFrameFormat* pFly: *pDoc->GetSpzFrameFormats()) + for( const auto pFly : *pDoc->GetSpzFrameFormats() ) { SwFormatAnchor const*const pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index e87a28ba4cfd..98fc0512acfd 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -349,7 +349,8 @@ sal_Int32 SwTextBoxHelper::getCount(SdrPage const* pPage) sal_Int32 SwTextBoxHelper::getCount(const SwDoc& rDoc) { sal_Int32 nRet = 0; - for (const sw::SpzFrameFormat* pFormat : *rDoc.GetSpzFrameFormats()) + const SwFrameFormats& rSpzFrameFormats = *rDoc.GetSpzFrameFormats(); + for (const auto pFormat : rSpzFrameFormats) { if (isTextBox(pFormat, RES_FLYFRMFMT)) ++nRet; @@ -959,7 +960,7 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_u xPropertySet->setPropertyValue(aPropertyName, aValue); } -void SwTextBoxHelper::saveLinks(const sw::FrameFormats<sw::SpzFrameFormat*>& rFormats, +void SwTextBoxHelper::saveLinks(const SwFrameFormats& rFormats, std::map<const SwFrameFormat*, const SwFrameFormat*>& rLinks) { for (const auto pFormat : rFormats) diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 8e055c5242bc..b9ae26a0e421 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1662,7 +1662,8 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // #i28006# Fly frames have to be restored even if the table was // #alone in the section - for(sw::SpzFrameFormat* pFly: *GetDoc().GetSpzFrameFormats()) + const SwFrameFormats& rFlyArr = *GetDoc().GetSpzFrameFormats(); + for( auto pFly : rFlyArr ) { SwFrameFormat *const pFormat = pFly; const SwFormatAnchor& rAnchor = pFormat->GetAnchor(); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index b69dec062a1f..91ac1697ea30 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -547,15 +547,16 @@ const SwPageDesc* SwNode::FindPageDesc( SwNodeOffset* pPgDescNdIdx ) const { // Find the right Anchor first const SwFrameFormat* pFormat = nullptr; - const sw::SpzFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats(); - for(sw::SpzFrameFormat* pSpz: rFormats) + for( size_t n = 0; n < rFormats.size(); ++n ) { - const SwFormatContent& rContent = pSpz->GetContent(); + const SwFrameFormat* pFrameFormat = rFormats[ n ]; + const SwFormatContent& rContent = pFrameFormat->GetContent(); if( rContent.GetContentIdx() && &rContent.GetContentIdx()->GetNode() == static_cast<SwNode const *>(pSttNd) ) { - pFormat = pSpz; + pFormat = pFrameFormat; break; } } @@ -750,17 +751,18 @@ SwFrameFormat* SwNode::GetFlyFormat() const if( !pRet ) { // The hard way through the Doc is our last way out - const sw::SpzFrameFormats& rSpzs = *GetDoc().GetSpzFrameFormats(); - for(sw::SpzFrameFormat* pSpz: rSpzs) + const SwFrameFormats& rFrameFormatTable = *GetDoc().GetSpzFrameFormats(); + for( size_t n = 0; n < rFrameFormatTable.size(); ++n ) { + SwFrameFormat* pFormat = rFrameFormatTable[n]; // Only Writer fly frames can contain Writer nodes. - if (pSpz->Which() != RES_FLYFRMFMT) + if (pFormat->Which() != RES_FLYFRMFMT) continue; - const SwFormatContent& rContent = pSpz->GetContent(); + const SwFormatContent& rContent = pFormat->GetContent(); if( rContent.GetContentIdx() && &rContent.GetContentIdx()->GetNode() == pSttNd ) { - pRet = pSpz; + pRet = pFormat; break; } } diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 5432119d8591..8675f62e72c9 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -751,10 +751,10 @@ SwDrawContact::~SwDrawContact() void SwDrawContact::GetTextObjectsFromFormat(std::list<SdrTextObj*>& o_rTextObjects, SwDoc& rDoc) { - for(sw::SpzFrameFormat* pFly: *rDoc.GetSpzFrameFormats()) + for(auto& rpFly : *rDoc.GetSpzFrameFormats()) { - if(dynamic_cast<const SwDrawFrameFormat*>(pFly)) - pFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects)); + if(dynamic_cast<const SwDrawFrameFormat*>(rpFly)) + rpFly->CallSwClientNotify(sw::CollectTextObjectsHint(o_rTextObjects)); } } @@ -1877,7 +1877,8 @@ void SwDrawContact::ConnectToLayout( const SwFormatAnchor* pAnch ) else { const SwNode& rIdx = *pAnch->GetAnchorNode(); - for(sw::SpzFrameFormat* pFlyFormat :*(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats())) + SwFrameFormats& rFormats = *(pDrawFrameFormat->GetDoc()->GetSpzFrameFormats()); + for( auto pFlyFormat : rFormats ) { if( pFlyFormat->GetContent().GetContentIdx() && rIdx == pFlyFormat->GetContent().GetContentIdx()->GetNode() ) diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index d5c03a14f1e0..11a3d945d447 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -93,7 +93,7 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) } // also delete surrounding FlyFrames if any - for(sw::SpzFrameFormat* pFly : *rClpDoc.GetSpzFrameFormats() ) + for( const auto pFly : *rClpDoc.GetSpzFrameFormats() ) { SwFormatAnchor const*const pAnchor = &pFly->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); @@ -144,13 +144,13 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* pNewClpText ) // assure the "RootFormat" is the first element in Spz-Array // (if necessary Flys were copied in Flys) - sw::SpzFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats(); + SwFrameFormats& rSpzFrameFormats = *rClpDoc.GetSpzFrameFormats(); if( rSpzFrameFormats[ 0 ] != pFlyFormat ) { #ifndef NDEBUG bool inserted = #endif - rSpzFrameFormats.newDefault(static_cast<sw::SpzFrameFormat*>(pFlyFormat)); + rSpzFrameFormats.newDefault( pFlyFormat ); assert( !inserted && "Fly not contained in Spz-Array" ); } @@ -688,7 +688,7 @@ namespace { return false; } - for(const sw::SpzFrameFormat* pSpzFormat: *pFormat->GetDoc()->GetSpzFrameFormats()) + for ( const auto& pSpzFormat : *pFormat->GetDoc()->GetSpzFrameFormats() ) { if (pSpzFormat->Which() != RES_FLYFRMFMT) { @@ -1043,7 +1043,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable) if(!Imp()->GetDrawView()) MakeDrawView(); ::std::vector<SwFrameFormat*> inserted; - for (sw::SpzFrameFormat* pFlyFormat: *rClpDoc.GetSpzFrameFormats()) + for (auto const pFlyFormat : *rClpDoc.GetSpzFrameFormats()) { // if anchored inside other fly, will be copied when copying // top-level fly, so skip here! (other non-body anchor @@ -1203,7 +1203,7 @@ void SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1 if( !rToFill.Imp()->GetDrawView() ) rToFill.MakeDrawView(); - for(sw::SpzFrameFormat* pCpyFormat: *GetDoc()->GetSpzFrameFormats()) + for ( auto pCpyFormat : *GetDoc()->GetSpzFrameFormats() ) { SwFormatAnchor aAnchor( pCpyFormat->GetAnchor() ); if ((RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId()) && diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 92f41ef0597e..3e1bb21df9f8 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1004,7 +1004,7 @@ void SwFEShell::GetPageObjs( std::vector<SwFrameFormat*>& rFillArr ) { rFillArr.clear(); - for(sw::SpzFrameFormat* pFormat : *mxDoc->GetSpzFrameFormats() ) + for( auto pFormat : *mxDoc->GetSpzFrameFormats() ) { if (RndStdIds::FLY_AT_PAGE == pFormat->GetAnchor().GetAnchorId()) { @@ -1026,7 +1026,7 @@ void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr ) bool bTmpAssert = false; for( auto pFormat : rFillArr ) { - if (mxDoc->GetSpzFrameFormats()->IsAlive(static_cast<sw::SpzFrameFormat*>(pFormat))) + if (mxDoc->GetSpzFrameFormats()->IsAlive(pFormat)) { // FlyFormat is still valid, therefore process @@ -1443,7 +1443,7 @@ SwFrameFormat* SwFEShell::WizardGetFly() { // do not search the Fly via the layout. Now we can delete a frame // without a valid layout. ( e.g. for the wizards ) - sw::SpzFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats(); + SwFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats(); if( !rSpzArr.empty() ) { SwNode& rCursorNd = GetCursor()->GetPoint()->GetNode(); diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 48a92366509c..01022e60a7d9 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -901,7 +901,7 @@ bool IsEmptyBox( const SwTableBox& rBox, SwPaM& rPam ) if( bRet ) { // now check for paragraph bound flies - const sw::SpzFrameFormats& rFormats = *rPam.GetDoc().GetSpzFrameFormats(); + const SwFrameFormats& rFormats = *rPam.GetDoc().GetSpzFrameFormats(); SwNodeOffset nSttIdx = rPam.GetPoint()->GetNodeIndex(), nEndIdx = rBox.GetSttNd()->EndOfSectionIndex(), nIdx; diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 3c8966f3147b..ca3c787e3954 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -21,7 +21,6 @@ #define INCLUDED_SW_SOURCE_CORE_INC_FRMTOOL_HXX #include <swtypes.hxx> -#include <frameformats.hxx> #include <BorderCacheOwner.hxx> #include "frame.hxx" #include "txtfrm.hxx" @@ -57,9 +56,10 @@ constexpr tools::Long BROWSE_HEIGHT = 56700 * 10; // 10 Meters #define GRFNUM_YES 1 #define GRFNUM_REPLACE 2 -void AppendObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pSpz, SwNodeOffset nIndex, SwFrame* pFrame, SwPageFrame* pPage, SwDoc* doc); +void AppendObjs( const SwFrameFormats *pTable, SwNodeOffset nIndex, + SwFrame *pFrame, SwPageFrame *pPage, SwDoc* doc ); -void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const* pTable, SwNodeOffset nIndex, +void AppendObjsOfNode(SwFrameFormats const* pTable, SwNodeOffset nIndex, SwFrame * pFrame, SwPageFrame * pPage, SwDoc * pDoc, std::vector<sw::Extent>::const_iterator const* pIter, std::vector<sw::Extent>::const_iterator const* pEnd, @@ -72,7 +72,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor); -void AppendAllObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pSpzs, const SwFrame* pSib); +void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib); // draw background with brush or graphics // The 6th parameter indicates that the method should consider background diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index b81a2fab65a9..b0f07c59f62b 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -2835,12 +2835,15 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const const SwFormatAnchor* pAnchor = &rFormat.GetAnchor(); if ((RndStdIds::FLY_AT_PAGE != pAnchor->GetAnchorId()) && pAnchor->GetAnchorNode()) { + const SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); const SwNode* pFlyNd = pAnchor->GetAnchorNode()->FindFlyStartNode(); while( pFlyNd ) { // then we walk up using the anchor - for(const sw::SpzFrameFormat* pFormat: *GetDoc()->GetSpzFrameFormats()) + size_t n; + for( n = 0; n < rFormats.size(); ++n ) { + const SwFrameFormat* pFormat = rFormats[ n ]; const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx(); if( pIdx && pFlyNd == &pIdx->GetNode() ) { @@ -2858,6 +2861,11 @@ bool SwFrameFormat::IsLowerOf( const SwFrameFormat& rFormat ) const break; } } + if( n >= rFormats.size() ) + { + OSL_ENSURE( false, "Fly section but no format found" ); + return false; + } } } return false; @@ -2931,8 +2939,8 @@ void SwFrameFormats::dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) cons } -SwFlyFrameFormat::SwFlyFrameFormat(SwAttrPool& rPool, const OUString &rFormatName, SwFrameFormat* pDerivedFrame) - : sw::SpzFrameFormat(rPool, rFormatName, pDerivedFrame, RES_FLYFRMFMT) +SwFlyFrameFormat::SwFlyFrameFormat( SwAttrPool& rPool, const OUString &rFormatNm, SwFrameFormat *pDrvdFrame ) + : SwFrameFormat( rPool, rFormatNm, pDrvdFrame, RES_FLYFRMFMT ) {} SwFlyFrameFormat::~SwFlyFrameFormat() @@ -3006,8 +3014,10 @@ void SwFlyFrameFormat::MakeFrames() if ( pModify == nullptr ) { const SwNode & rNd = *aAnchorAttr.GetAnchorNode(); - for(sw::SpzFrameFormat* pFlyFormat: *GetDoc()->GetSpzFrameFormats()) + SwFrameFormats& rFormats = *GetDoc()->GetSpzFrameFormats(); + for( size_t i = 0; i < rFormats.size(); ++i ) { + SwFrameFormat* pFlyFormat = rFormats[i]; if( pFlyFormat->GetContent().GetContentIdx() && rNd == pFlyFormat->GetContent().GetContentIdx()->GetNode() ) { @@ -3670,24 +3680,25 @@ void CheckAnchoredFlyConsistency(SwDoc const& rDoc) assert(rAnchor.GetAnchorNode() == pNode); } } - if(!rDoc.GetSpzFrameFormats()) + SwFrameFormats const*const pSpzFrameFormats(rDoc.GetSpzFrameFormats()); + if (!pSpzFrameFormats) return; - for(sw::SpzFrameFormat* pSpz: *rDoc.GetSpzFrameFormats()) + for (auto it = pSpzFrameFormats->begin(); it != pSpzFrameFormats->end(); ++it) { - SwFormatAnchor const& rAnchor(pSpz->GetAnchor(false)); + SwFormatAnchor const& rAnchor((**it).GetAnchor(false)); if (RndStdIds::FLY_AT_PAGE == rAnchor.GetAnchorId()) { assert(!rAnchor.GetAnchorNode() // for invalid documents that lack text:anchor-page-number // it may have an anchor before MakeFrames() is called - || (!SwIterator<SwFrame, SwFrameFormat>(*pSpz).First())); + || (!SwIterator<SwFrame, SwFrameFormat>(**it).First())); } else { SwNode & rNode(*rAnchor.GetAnchorNode()); std::vector<SwFrameFormat*> const& rFlys(rNode.GetAnchoredFlys()); - assert(std::find(rFlys.begin(), rFlys.end(), pSpz) != rFlys.end()); + assert(std::find(rFlys.begin(), rFlys.end(), *it) != rFlys.end()); switch (rAnchor.GetAnchorId()) { case RndStdIds::FLY_AT_FLY: diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 193478da450e..057ce8adad9e 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -953,8 +953,11 @@ void SwContentNotify::ImplDestroy() // the page is known. Thus, this data can be corrected now. const SwPageFrame *pPage = nullptr; - for(sw::SpzFrameFormat* pFormat: *rDoc.GetSpzFrameFormats()) + SwFrameFormats *pTable = rDoc.GetSpzFrameFormats(); + + for ( size_t i = 0; i < pTable->size(); ++i ) { + SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( RndStdIds::FLY_AT_PAGE != rAnch.GetAnchorId() || rAnch.GetAnchorNode() == nullptr ) @@ -1225,7 +1228,7 @@ void RemoveHiddenObjsOfNode(SwTextNode const& rNode, } } -void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const*const pTable, SwNodeOffset const nIndex, +void AppendObjsOfNode(SwFrameFormats const*const pTable, SwNodeOffset const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc, std::vector<sw::Extent>::const_iterator const*const pIter, std::vector<sw::Extent>::const_iterator const*const pEnd, @@ -1233,8 +1236,9 @@ void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const*const pTable, { #if OSL_DEBUG_LEVEL > 0 std::vector<SwFrameFormat*> checkFormats; - for(auto pFormat: *pTable) + for ( size_t i = 0; i < pTable->size(); ++i ) { + SwFrameFormat *pFormat = (*pTable)[i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( rAnch.GetAnchorNode() && IsShown(nIndex, rAnch, pIter, pEnd, pFirstNode, pLastNode)) @@ -1271,7 +1275,7 @@ void AppendObjsOfNode(sw::FrameFormats<sw::SpzFrameFormat*> const*const pTable, } -void AppendObjs(const sw::FrameFormats<sw::SpzFrameFormat*> *const pTable, SwNodeOffset const nIndex, +void AppendObjs(const SwFrameFormats *const pTable, SwNodeOffset const nIndex, SwFrame *const pFrame, SwPageFrame *const pPage, SwDoc *const pDoc) { if (pFrame->IsTextFrame()) @@ -1374,7 +1378,7 @@ bool IsAnchoredObjShown(SwTextFrame const& rFrame, SwFormatAnchor const& rAnchor return ret; } -void AppendAllObjs(const sw::FrameFormats<sw::SpzFrameFormat*>* pTable, const SwFrame* pSib) +void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib) { //Connecting of all Objects, which are described in the SpzTable with the //layout. @@ -1510,7 +1514,7 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, const bool bStartPercent = bPages && !nEndIndex; SwPageFrame *pPage = pLay->FindPageFrame(); - sw::SpzFrameFormats* pTable = pDoc->GetSpzFrameFormats(); + const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); SwFrame *pFrame = nullptr; std::unique_ptr<SwActualSection> pActualSection; std::unique_ptr<SwLayHelper> pPageMaker; @@ -2167,7 +2171,7 @@ void MakeFrames( SwDoc *pDoc, SwNode &rSttIdx, SwNode &rEndIdx ) // depend on value of <bAllowMove> if( !isFlyCreationSuppressed ) { - const sw::SpzFrameFormats* pTable = pDoc->GetSpzFrameFormats(); + const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); if( !pTable->empty() ) AppendAllObjs( pTable, pUpper ); } diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index da29a0654eb9..152368d9d913 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -395,13 +395,14 @@ static void lcl_FormatLay( SwLayoutFrame *pLay ) } /// Create Flys or register draw objects -static void lcl_MakeObjs(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, SwPageFrame* pPage) +static void lcl_MakeObjs( const SwFrameFormats &rTable, SwPageFrame *pPage ) { // formats are in the special table of the document - for(size_t i = 0; i < rSpzs.size(); ++i ) + + for ( size_t i = 0; i < rTable.size(); ++i ) { - auto pSpz = rSpzs[i]; - const SwFormatAnchor &rAnch = pSpz->GetAnchor(); + SwFrameFormat *pFormat = rTable[i]; + const SwFormatAnchor &rAnch = pFormat->GetAnchor(); if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() ) { if( rAnch.GetAnchorNode() ) @@ -410,19 +411,19 @@ static void lcl_MakeObjs(const sw::FrameFormats<sw::SpzFrameFormat*>& rSpzs, SwP { ... etc. - the rest is truncated