[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/IDocumentMarkAccess.hxx |2 + sw/qa/uibase/uno/uno.cxx | 32 ++ sw/source/core/doc/docbm.cxx | 23 +++ sw/source/core/inc/MarkManager.hxx |1 sw/source/uibase/uno/loktxdoc.cxx | 44 +++-- 5 files changed, 100 insertions(+), 2 deletions(-) New commits: commit d7c10661a7b4f6d9d28d2a43829c3c28f590fbaa Author: Miklos Vajna AuthorDate: Wed Jan 11 10:38:05 2023 +0100 Commit: Miklos Vajna CommitDate: Thu Jan 12 16:03:32 2023 + sw lok: expose name of bookmark under cursor It was possible to get the names of all bookmarks, but you could not get the name of the (innermost) bookmark under the current cursor. Getting the name of the current bookmark is useful for Zotero: if we already have a citation and want to insert one more, then we should turn the current citation into a citation cluster. Fix the problem by adding an API similar to what commit bb20dee2ef1b0804065e1cda2c834d257fdd90ed (sw lok: expose field type & command of fieldmark under cursor, 2023-01-05) did, but here we deal with bookmarks, not fieldmarks. Handle the actual bookmark lookup in MarkManager, such functionality looks useful outside LOK as well. (cherry picked from commit 4bcb66ec7b417fbe113267f2615e78fe47eb55ca) Change-Id: Ic5b9b36fda243c5d7d360fa03745b3e121b67b06 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145348 Tested-by: Jenkins CollaboraOffice Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index d7f3bdd6674b..9ff1a311768a 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -314,6 +314,8 @@ class IDocumentMarkAccess */ virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const =0; +/// Get the innermost bookmark that contains rPos. +virtual sw::mark::IMark* getBookmarkFor(const SwPosition& rPos) const = 0; // Fieldmarks /** returns a STL-like random access iterator to the begin of the sequence of fieldmarks. diff --git a/sw/qa/uibase/uno/uno.cxx b/sw/qa/uibase/uno/uno.cxx index 300278717664..595987eea423 100644 --- a/sw/qa/uibase/uno/uno.cxx +++ b/sw/qa/uibase/uno/uno.cxx @@ -336,6 +336,38 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetSections) CPPUNIT_ASSERT_EQUAL(static_cast(1), aTree.get_child("sections").count("")); } +CPPUNIT_TEST_FIXTURE(SwUibaseUnoTest, testGetBookmark) +{ +// Given a document with a bookmark: +SwDoc* pDoc = createSwDoc(); +uno::Sequence aArgs = { +comphelper::makePropertyValue("Bookmark", uno::Any(OUString("ZOTERO_BREF_1"))), +comphelper::makePropertyValue("BookmarkText", uno::Any(OUString("aaabbb"))), +}; +dispatchCommand(mxComponent, ".uno:InsertBookmark", aArgs); + +// When stepping into the bookmark with the cursor and getting the command value for +// .uno:Bookmark: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->SttEndDoc(/*bStt=*/false); +pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); +tools::JsonWriter aJsonWriter; +OString aCommand(".uno:Bookmark?namePrefix=ZOTERO_BREF_"); +auto pXTextDocument = dynamic_cast(mxComponent.get()); +pXTextDocument->getCommandValues(aJsonWriter, aCommand); + +// Then make sure we find the inserted bookmark: +std::unique_ptr pJSON(aJsonWriter.extractData()); +std::stringstream aStream(pJSON.get()); +boost::property_tree::ptree aTree; +boost::property_tree::read_json(aStream, aTree); +boost::property_tree::ptree aBookmark = aTree.get_child("bookmark"); +// Without the accompanying fix in place, this test would have failed with: +// - No such node (bookmark) +// i.e. the returned JSON was an empty object. +CPPUNIT_ASSERT_EQUAL(std::string("ZOTERO_BREF_1"), aBookmark.get("name")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index bc9884c2829e..fcce59889b48 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1421,6 +1421,29 @@ namespace sw::mark return dynamic_cast(pFieldmark); } +IMark* MarkManager::getBookmarkFor(const SwPosition& rPos) const +{ +auto it = std::find_if(m_vBookmarks.begin(), m_vBookmarks.end(), + [&rPos](const sw::mark::MarkBase* pMark) + { return pMark->IsCoveringPosition(rPos); }); +if (it == m_vBookmarks.end()) +{ +return nullptr; +} +sw::mark::IMark* pBookmark = *it; +for (; it != m_vBookmarks.end() && (*it)->GetMarkStart() <= rPos; ++it) +{ +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/textboxhelper.hxx | 11 +++ sw/qa/extras/uiwriter/data/tdf149550.docx|binary sw/qa/extras/uiwriter/uiwriter4.cxx | 25 sw/source/core/doc/DocumentLayoutManager.cxx | 65 + sw/source/core/doc/textboxhelper.cxx | 81 ++- 5 files changed, 120 insertions(+), 62 deletions(-) New commits: commit d981737bcebf825949cd8b13c2c609a109abc984 Author: Attila Bakos (NISZ) AuthorDate: Tue Jun 14 10:38:46 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Jan 17 09:25:29 2023 + tdf#149550 sw: fix crash by implementing nested textbox copy Grouped shapes with a nested textbox were copied without the textbox with frequent crashing. Regression from commit 2951cbdf3a6e2b62461665546b47e1d253fcb834 "tdf#143574 OOXML export/import of textboxes in group shapes". Change-Id: Ie2cc24f10706d8999026dc92ebad21f2c5673003 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135815 Tested-by: László Németh Reviewed-by: László Németh Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143370 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index a389634c60eb..b0ab5618b466 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -27,6 +27,7 @@ class SdrObject; class SfxItemSet; class SwFrameFormat; class SwFrameFormats; +class SwFormatAnchor; class SwFormatContent; class SwDoc; namespace tools @@ -204,6 +205,8 @@ class SwTextBoxNode // (and the textboxes) SwFrameFormat* m_pOwnerShapeFormat; +mutable bool m_bIsCloningInProgress; + public: // Not needed. SwTextBoxNode() = delete; @@ -251,6 +254,14 @@ public: size_t GetTextBoxCount() const { return m_pTextBoxes.size(); }; // Returns with a const collection of textboxes owned by this node. std::map GetAllTextBoxes() const; + +void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* o_pTarget, bool bSetAttr, + bool bMakeFrame) const; + +private: +void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* o_pTarget, +const SdrObject* pSrcObj, SdrObject* pDestObj, bool bSetAttr, +bool bMakeFrame) const; }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx b/sw/qa/extras/uiwriter/data/tdf149550.docx new file mode 100644 index ..3434fc1fff93 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149550.docx differ diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index fc7bd27e3124..76f0506d52fa 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -292,6 +292,7 @@ public: void testInsertPdf(); void testTdf143760WrapContourToOff(); void testHatchFill(); +void testNestedGroupTextBoxCopyCrash(); CPPUNIT_TEST_SUITE(SwUiWriterTest4); CPPUNIT_TEST(testTdf96515); @@ -417,6 +418,7 @@ public: CPPUNIT_TEST(testInsertPdf); CPPUNIT_TEST(testTdf143760WrapContourToOff); CPPUNIT_TEST(testHatchFill); +CPPUNIT_TEST(testNestedGroupTextBoxCopyCrash); CPPUNIT_TEST_SUITE_END(); }; @@ -4140,6 +4142,29 @@ void SwUiWriterTest4::testHatchFill() CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), "FillTransparence")); } +void SwUiWriterTest4::testNestedGroupTextBoxCopyCrash() +{ +createSwDoc(DATA_DIRECTORY, "tdf149550.docx"); + +dispatchCommand(mxComponent, ".uno:SelectAll", {}); +Scheduler::ProcessEventsToIdle(); +dispatchCommand(mxComponent, ".uno:Copy", {}); +Scheduler::ProcessEventsToIdle(); +// This crashed here before the fix. +SwXTextDocument* pXTextDocument = dynamic_cast(mxComponent.get()); +CPPUNIT_ASSERT(pXTextDocument); +pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE); +Scheduler::ProcessEventsToIdle(); +dispatchCommand(mxComponent, ".uno:Paste", {}); +Scheduler::ProcessEventsToIdle(); + +CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", mxComponent); + +auto pLayout = parseLayoutDump(); +// There must be 2 textboxes! +assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index 006501b3aa36..a03d5dc1d60d 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -463,67 +463,6 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( if( bMakeFrames ) pDest->MakeFrames(); -// If the draw format has a TextBox, then copy its fly format as well. -if (rSource.Which() == RES_DRAWFRMFMT && rSource.GetOtherTextBoxFormats
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/IDocumentMarkAccess.hxx |4 ++-- sw/inc/crsrsh.hxx |4 ++-- sw/qa/extras/uiwriter/uiwriter4.cxx |2 +- sw/source/core/crsr/crbm.cxx|8 sw/source/core/doc/docbm.cxx| 27 --- sw/source/core/inc/MarkManager.hxx |4 ++-- sw/source/ui/vba/vbaformfield.cxx | 10 ++ sw/source/uibase/docvw/edtwin.cxx |6 -- sw/source/uibase/wrtsh/wrtsh1.cxx |4 ++-- 9 files changed, 43 insertions(+), 26 deletions(-) New commits: commit 28b55ce5943712ffa17f5e9a35d5945765fc71fe Author: Justin Luth AuthorDate: Mon Jan 23 11:18:44 2023 -0500 Commit: Miklos Vajna CommitDate: Tue Feb 7 07:19:49 2023 + related tdf#151548 formfield navigation: loop to beginning/end When reaching the end of the form using keyboard navigation, the next tabstop should return the user to the beginning of the form. This patch adds that to the existing legacy formfield navigation. I'll wait with a unit test until I have added activeX/contentControls into the mix. Change-Id: I24a15a60f5a0a2721f512cca50397efddcbf7e4b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146035 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146562 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index 9ff1a311768a..03c3dcfce648 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -329,8 +329,8 @@ class IDocumentMarkAccess /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0; virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0; -virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0; -virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0; +virtual sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos, bool bLoop) const =0; +virtual sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos, bool bLoop) const =0; virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0; virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const=0; diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 9f79a515153a..25e95c415fa4 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -571,8 +571,8 @@ public: bool IsFormProtected(); ::sw::mark::IFieldmark* GetCurrentFieldmark(); -::sw::mark::IFieldmark* GetFieldmarkAfter(); -::sw::mark::IFieldmark* GetFieldmarkBefore(); +sw::mark::IFieldmark* GetFieldmarkAfter(bool bLoop); +sw::mark::IFieldmark* GetFieldmarkBefore(bool bLoop); bool GotoFieldmark( const ::sw::mark::IFieldmark* const pMark ); // update Cursr, i.e. reset it into content should only be called when the diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 76f0506d52fa..967ed5007522 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -1447,7 +1447,7 @@ void SwUiWriterTest4::testTdf95699() pMarkAccess = aClipboard.getIDocumentMarkAccess(); CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount()); ::sw::mark::IFieldmark* pFieldMark -= pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras())); += pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()), false); CPPUNIT_ASSERT_EQUAL(OUString("vnd.oasis.opendocument.field.FORMCHECKBOX"), pFieldMark->GetFieldname()); } diff --git a/sw/source/core/crsr/crbm.cxx b/sw/source/core/crsr/crbm.cxx index bb17940a01d6..d171b1d52be1 100644 --- a/sw/source/core/crsr/crbm.cxx +++ b/sw/source/core/crsr/crbm.cxx @@ -290,16 +290,16 @@ bool SwCursorShell::IsFormProtected() return getIDocumentMarkAccess()->getFieldmarkFor(pos); } -::sw::mark::IFieldmark* SwCursorShell::GetFieldmarkAfter() +sw::mark::IFieldmark* SwCursorShell::GetFieldmarkAfter(bool bLoop) { SwPosition pos(*GetCursor()->GetPoint()); -return getIDocumentMarkAccess()->getFieldmarkAfter(pos); +return getIDocumentMarkAccess()->getFieldmarkAfter(pos, bLoop); } -::sw::mark::IFieldmark* SwCursorShell::GetFieldmarkBefore() +sw::mark::IFieldmark* SwCursorShell::GetFieldmarkBefore(bool bLoop) { SwPosition pos(*GetCursor()->GetPoint()); -return getIDocumentMarkAccess()->getFieldmarkBefore(pos); +return getIDocumentMarkAccess()->getFieldmarkBefore(pos, bLoop); } bool SwCursorShell::GotoFieldmark(::sw::mark::IFieldmark const * const pMark) diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/IDocumentMarkAccess.hxx |3 sw/inc/crsrsh.hxx |2 sw/inc/textcontentcontrol.hxx |1 sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm |binary sw/qa/extras/uiwriter/uiwriter4.cxx | 41 + sw/source/core/crsr/crstrvl.cxx | 126 sw/source/core/doc/docbm.cxx|2 sw/source/core/inc/MarkManager.hxx |1 sw/source/core/txtnode/attrcontentcontrol.cxx |6 sw/source/uibase/docvw/edtwin.cxx | 39 +++- 10 files changed, 211 insertions(+), 10 deletions(-) New commits: commit 57368915108756573026509efdc4303fe4141027 Author: Justin Luth AuthorDate: Thu Jan 26 14:50:19 2023 -0500 Commit: Miklos Vajna CommitDate: Tue Feb 7 07:50:20 2023 + tdf#151548 sw content controls: keyboard navigation with tab key Combine content controls with legacy formfield controls in keyboard tab navigation. MS Word (I tested 2010) is extremely irrational and inconsistent in its behaviour, so I modeled my implementation on the specification and general logic, and not at all on "compatible misbehaviour". There is a third category of form control (activeX rich content), but these are mapped to internal LO controls that are only exposed at VCL level, and don't pass the keystrokes back to SW. Plus, they are not inline, but fly controls. However, it is still a TODO to handle these if reasonably possible. Change-Id: I1fef34d05a779e9d4f549987238435acb6c043d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146219 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146563 Tested-by: Jenkins CollaboraOffice diff --git a/sw/inc/IDocumentMarkAccess.hxx b/sw/inc/IDocumentMarkAccess.hxx index 03c3dcfce648..93991cdd1987 100644 --- a/sw/inc/IDocumentMarkAccess.hxx +++ b/sw/inc/IDocumentMarkAccess.hxx @@ -326,6 +326,9 @@ class IDocumentMarkAccess */ virtual const_iterator_t getFieldmarksEnd() const =0; +/// returns the number of IFieldmarks. +virtual sal_Int32 getFieldmarksCount() const = 0; + /// get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0; virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0; diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 25e95c415fa4..431cdd503ab3 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -709,6 +709,8 @@ public: bool GotoFormatContentControl(const SwFormatContentControl& rContentControl); +void GotoFormControl(bool bNext); + static SwTextField* GetTextFieldAtPos( const SwPosition* pPos, const bool bIncludeInputFieldAtStart ); diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx index 3fb7ea124b99..b3926bd25ce9 100644 --- a/sw/inc/textcontentcontrol.hxx +++ b/sw/inc/textcontentcontrol.hxx @@ -64,6 +64,7 @@ public: size_t GetCount() const { return m_aContentControls.size(); } bool IsEmpty() const { return m_aContentControls.empty(); } SwTextContentControl* Get(size_t nIndex); +SwTextContentControl* UnsortedGet(size_t nIndex); void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm b/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm new file mode 100644 index ..1b173e2041c2 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf151548_tabNavigation.docm differ diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 967ed5007522..715f58334002 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -195,6 +195,7 @@ public: void testCursorWindows(); void testLandscape(); void testTdf95699(); +void testTdf151548_tabNavigation(); void testTdf104032(); void testTdf104440(); void testTdf104425(); @@ -324,6 +325,7 @@ public: CPPUNIT_TEST(testCursorWindows); CPPUNIT_TEST(testLandscape); CPPUNIT_TEST(testTdf95699); +CPPUNIT_TEST(testTdf151548_tabNavigation); CPPUNIT_TEST(testTdf104032); CPPUNIT_TEST(testTdf104440); CPPUNIT_TEST(testTdf104425); @@ -1452,6 +1454,45 @@ void SwUiWriterTest4::testTdf95699() pFieldMark->GetFieldname()); } +void SwUiWriterTest4::testTdf151548_tabNavigation() +{ +// given a form-protected doc with 4 unchecked legacy fieldmark checkboxes (and several modern +// content controls which all have a tabstop of -1 to disable tabstop navigation to them) +// we want to test that tab navigation complet
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/textcontentcontrol.hxx |2 ++ sw/qa/core/data/docm/testModernVBA.docm |binary sw/source/core/txtnode/attrcontentcontrol.cxx | 17 + sw/source/ui/vba/vbacontentcontrol.cxx|5 ++--- 4 files changed, 21 insertions(+), 3 deletions(-) New commits: commit 216764d08954132d4b7cae0b8e6b8382c0b30e1b Author: Justin Luth AuthorDate: Wed Nov 23 18:12:20 2022 -0500 Commit: Miklos Vajna CommitDate: Thu Dec 15 08:18:58 2022 + tdf#151548 ContentControls: Add Delete() Needed a function to delete a control, so it seemed to make sense to include it here. [I saw a nice bExact flag, but it doesn't work because RES_TXTATTR_CONTENTCONTROLS is outside of a certain range. Oh well.] make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME=testVba Change-Id: If7da3d4d614d9dfd20f539f651477cbd18d25e20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143195 Tested-by: Jenkins Reviewed-by: Justin Luth Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144013 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx index a9bc4e4a1054..3fb7ea124b99 100644 --- a/sw/inc/textcontentcontrol.hxx +++ b/sw/inc/textcontentcontrol.hxx @@ -41,6 +41,8 @@ public: void ChgTextNode(SwTextNode* pNode); +void Delete(bool bSaveContents); + SwTextNode* GetTextNode() const; /// Get the current (potentially invalid) string from the doc OUString ToString() const; diff --git a/sw/qa/core/data/docm/testModernVBA.docm b/sw/qa/core/data/docm/testModernVBA.docm index dd96686659ca..be7d99a24b84 100644 Binary files a/sw/qa/core/data/docm/testModernVBA.docm and b/sw/qa/core/data/docm/testModernVBA.docm differ diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index b1d781f48d48..8542423e8696 100644 --- a/sw/source/core/txtnode/attrcontentcontrol.cxx +++ b/sw/source/core/txtnode/attrcontentcontrol.cxx @@ -669,6 +669,23 @@ void SwTextContentControl::ChgTextNode(SwTextNode* pNode) } } +void SwTextContentControl::Delete(bool bSaveContents) +{ +if (!GetTextNode()) +return; + +if (bSaveContents) +{ +SwIndex aStart(GetTextNode(), GetStart()); +GetTextNode()->RstTextAttr(aStart, *End() - GetStart(), RES_TXTATR_CONTENTCONTROL); +} +else +{ +SwPaM aPaM(*GetTextNode(), GetStart(), *GetTextNode(), *End()); + GetTextNode()->GetDoc().getIDocumentContentOperations().DeleteAndJoin(aPaM); +} +} + SwTextNode* SwTextContentControl::GetTextNode() const { auto& rFormatContentControl = static_cast(GetAttr()); diff --git a/sw/source/ui/vba/vbacontentcontrol.cxx b/sw/source/ui/vba/vbacontentcontrol.cxx index d75ce84d7f4a..da3f3ec6f4ee 100644 --- a/sw/source/ui/vba/vbacontentcontrol.cxx +++ b/sw/source/ui/vba/vbacontentcontrol.cxx @@ -676,15 +676,14 @@ void SwVbaContentControl::Cut() SAL_INFO("sw.vba", "SwVbaContentControl::Cut[" << getID() << "], but missing sending to clipboard"); -Delete(uno::Any(false)); +m_rCC.Delete(/*bSaveContents=*/false); } void SwVbaContentControl::Delete(const uno::Any& DeleteContents) { bool bDeleteContents = false; DeleteContents >>= bDeleteContents; -SAL_INFO("sw.vba", "SwVbaContentControl::Delete[" << DeleteContents << "] stub"); -//m_rCC.ChgTextNode(nullptr); // works, but crashes on UI touch - probably requires invalidation +m_rCC.Delete(!bDeleteContents); } void SwVbaContentControl::SetCheckedSymbol(sal_Int32 Character, const uno::Any& Font)
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/strings.hrc |1 sw/qa/extras/ooxmlexport/data/tdf125338.docm |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx| 10 ++- sw/source/filter/ww8/docxexport.cxx |3 +- sw/source/filter/ww8/docxexportfilter.cxx| 35 +++ 5 files changed, 43 insertions(+), 6 deletions(-) New commits: commit 39a09050d309de7ebcf4630cc12cdffa2ca4a654 Author: offtkp AuthorDate: Wed Dec 14 22:21:34 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Sat Jan 7 16:05:58 2023 + tdf#125338 Do not export macros when saving as .docx Docx files that have macros should be saved as .docm. Now displays a warning that macros won't be saved if exporting a .docm as a .docx and doesn't export them. Change-Id: I178855baa6c0a7d32fd9b00c83a817230b33a1a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144197 Tested-by: Jenkins Reviewed-by: Justin Luth (cherry picked from commit cbca5617387aaa39c9ee86272166bb3df7874b25) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144811 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/strings.hrc b/sw/inc/strings.hrc index b4b03968a1eb..59fe112fecba 100644 --- a/sw/inc/strings.hrc +++ b/sw/inc/strings.hrc @@ -331,6 +331,7 @@ #define STR_SOUTH NC_("STR_SOUTH", "South") #define STR_SUM NC_("STR_SUM", "Sum") #define STR_INVALID_AUTOFORMAT_NAME NC_("STR_INVALID_AUTOFORMAT_NAME", "You have entered an invalid name.\nThe desired AutoFormat could not be created. \nTry again using a different name.") +#define STR_CANT_SAVE_MACROSNC_("STR_CANT_SAVE_MACROS", "This document has macros, but macros will not be saved in this file format.") #define STR_NUMERIC NC_("STR_NUMERIC", "Numeric") #define STR_ROW NC_("STR_ROW", "Rows") #define STR_COL NC_("STR_COL", "Column") diff --git a/sw/qa/extras/ooxmlexport/data/tdf125338.docm b/sw/qa/extras/ooxmlexport/data/tdf125338.docm new file mode 100644 index ..44e943531d30 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125338.docm differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 99d4b0112a60..1b97e846f1ef 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -139,7 +139,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx") CPPUNIT_ASSERT_EQUAL(0, getShapes()); } -CPPUNIT_TEST_FIXTURE(Test, testTdf108269) +CPPUNIT_TEST_FIXTURE(DocmTest, testTdf108269) { loadAndReload("tdf108269.docm"); uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); @@ -149,6 +149,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf108269) CPPUNIT_ASSERT(xNameAccess->hasByName("word/vbaData.xml")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf125338) +{ +loadAndSave("tdf125338.docm"); +uno::Reference xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); +// docm files should not retain macros when saved as docx +CPPUNIT_ASSERT(!xNameAccess->hasByName("word/vbaProject.bin")); +} + DECLARE_OOXMLEXPORT_TEST(testTdf92045, "tdf92045.docx") { // This was true, resulted in setting the blinking font effect. diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 74d081baf244..d5bc243d5c2e 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -538,7 +538,8 @@ ErrCode DocxExport::ExportDocument_Impl() WriteEmbeddings(); -WriteVBA(); +if (m_bDocm) +WriteVBA(); m_aLinkedTextboxesHelper.clear(); //final cleanup m_pStyles.reset(); diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx index 08308ca9398c..5ffd32f4c25b 100644 --- a/sw/source/filter/ww8/docxexportfilter.cxx +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -63,6 +63,37 @@ bool DocxExportFilter::exportDocument() pViewShell->GetPostItMgr()->UpdateDataOnActiveSidebarWin(); } +OUString aFilterName; +auto& rMediaDescriptor = getMediaDescriptor(); +rMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] >>= aFilterName; +bool bDocm = aFilterName.endsWith("VBA"); + +if (!bDocm) +{ +// Check whether application is in headless mode +if (!Application::IsHeadlessModeEnabled()) +{ +uno::Reference xStorageBasedDocument( +pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY); +if (xStorageBasedDocument.is()) +{ +uno::Reference xDocumentStorage = +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
dev/null |binary sw/inc/textboxhelper.hxx | 11 --- sw/qa/extras/uiwriter/uiwriter4.cxx | 25 sw/source/core/doc/DocumentLayoutManager.cxx | 65 - sw/source/core/doc/textboxhelper.cxx | 81 --- 5 files changed, 62 insertions(+), 120 deletions(-) New commits: commit a4ea14695a8e7b7beeb89fae170df2f7ec9f4171 Author: Justin Luth AuthorDate: Wed Apr 12 08:20:48 2023 -0400 Commit: Andras Timar CommitDate: Wed Apr 12 21:32:36 2023 +0200 Revert "tdf#149550 sw: fix crash by implementing nested textbox copy" This reverts commit d981737bcebf825949cd8b13c2c609a109abc984. It was added for T38690 and removed for T41585 Change-Id: Iae7f0f273f81f050a2fbfa589451e6039a1a2193 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150291 Reviewed-by: Justin Luth Reviewed-by: Andras Timar Tested-by: Andras Timar diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index b0ab5618b466..a389634c60eb 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -27,7 +27,6 @@ class SdrObject; class SfxItemSet; class SwFrameFormat; class SwFrameFormats; -class SwFormatAnchor; class SwFormatContent; class SwDoc; namespace tools @@ -205,8 +204,6 @@ class SwTextBoxNode // (and the textboxes) SwFrameFormat* m_pOwnerShapeFormat; -mutable bool m_bIsCloningInProgress; - public: // Not needed. SwTextBoxNode() = delete; @@ -254,14 +251,6 @@ public: size_t GetTextBoxCount() const { return m_pTextBoxes.size(); }; // Returns with a const collection of textboxes owned by this node. std::map GetAllTextBoxes() const; - -void Clone(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* o_pTarget, bool bSetAttr, - bool bMakeFrame) const; - -private: -void Clone_Impl(SwDoc* pDoc, const SwFormatAnchor& rNewAnc, SwFrameFormat* o_pTarget, -const SdrObject* pSrcObj, SdrObject* pDestObj, bool bSetAttr, -bool bMakeFrame) const; }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/qa/extras/uiwriter/data/tdf149550.docx b/sw/qa/extras/uiwriter/data/tdf149550.docx deleted file mode 100644 index 3434fc1fff93.. Binary files a/sw/qa/extras/uiwriter/data/tdf149550.docx and /dev/null differ diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 715f58334002..575e71681685 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -293,7 +293,6 @@ public: void testInsertPdf(); void testTdf143760WrapContourToOff(); void testHatchFill(); -void testNestedGroupTextBoxCopyCrash(); CPPUNIT_TEST_SUITE(SwUiWriterTest4); CPPUNIT_TEST(testTdf96515); @@ -420,7 +419,6 @@ public: CPPUNIT_TEST(testInsertPdf); CPPUNIT_TEST(testTdf143760WrapContourToOff); CPPUNIT_TEST(testHatchFill); -CPPUNIT_TEST(testNestedGroupTextBoxCopyCrash); CPPUNIT_TEST_SUITE_END(); }; @@ -4183,29 +4181,6 @@ void SwUiWriterTest4::testHatchFill() CPPUNIT_ASSERT_EQUAL(sal_Int32(30), getProperty(getShape(1), "FillTransparence")); } -void SwUiWriterTest4::testNestedGroupTextBoxCopyCrash() -{ -createSwDoc(DATA_DIRECTORY, "tdf149550.docx"); - -dispatchCommand(mxComponent, ".uno:SelectAll", {}); -Scheduler::ProcessEventsToIdle(); -dispatchCommand(mxComponent, ".uno:Copy", {}); -Scheduler::ProcessEventsToIdle(); -// This crashed here before the fix. -SwXTextDocument* pXTextDocument = dynamic_cast(mxComponent.get()); -CPPUNIT_ASSERT(pXTextDocument); -pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_ESCAPE); -Scheduler::ProcessEventsToIdle(); -dispatchCommand(mxComponent, ".uno:Paste", {}); -Scheduler::ProcessEventsToIdle(); - -CPPUNIT_ASSERT_MESSAGE("Where is the doc, it crashed, isn't it?!", mxComponent); - -auto pLayout = parseLayoutDump(); -// There must be 2 textboxes! -assertXPath(pLayout, "/root/page/body/txt/anchored/fly[2]"); -} - CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest4); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx b/sw/source/core/doc/DocumentLayoutManager.cxx index a03d5dc1d60d..006501b3aa36 100644 --- a/sw/source/core/doc/DocumentLayoutManager.cxx +++ b/sw/source/core/doc/DocumentLayoutManager.cxx @@ -463,6 +463,67 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat( if( bMakeFrames ) pDest->MakeFrames(); +// If the draw format has a TextBox, then copy its fly format as well. +if (rSource.Which() == RES_DRAWFRMFMT && rSource.GetOtherTextBoxFormats()) +{ +auto pObj = rSource.FindRealSdrObject(); +auto pTextBoxNd = std::make_shared(SwTextBoxNode(pDest)); +pDest->SetOtherTextBoxFormats(pTextBoxNd); + +if (pObj) +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
dev/null|binary sw/inc/textboxhelper.hxx| 16 -- sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py | 127 sw/source/core/doc/docdraw.cxx | 56 +--- sw/source/core/doc/textboxhelper.cxx| 82 +--- sw/source/core/draw/dcontact.cxx|6 sw/source/core/draw/dview.cxx |9 - sw/source/core/unocore/unodraw.cxx | 15 -- 8 files changed, 32 insertions(+), 279 deletions(-) New commits: commit 6263b7bbff3bdbe1bba0f168fb363b07f60377cf Author: Justin Luth AuthorDate: Wed Apr 12 09:27:29 2023 -0400 Commit: Andras Timar CommitDate: Wed Apr 12 21:33:37 2023 +0200 Revert "tdf#143574 sw: textboxes in group shapes - part 3 take 2" This reverts commit d3daa7ed0361785d8667f726340538ada1607937. It was added for T38690 and removed for T41585 There was no urgency to get T38690 out, so these regression-prone patches should not have been backported into to a stable product. All of these patches are in master and LO 7.4, so they will be part of 23.05 already. So T38690 is solved still in 23.05. Change-Id: I113fb13ea9ca62f63d6e74a0da77108ba32cc440 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150296 Reviewed-by: Andras Timar Tested-by: Andras Timar diff --git a/sw/inc/textboxhelper.hxx b/sw/inc/textboxhelper.hxx index 924b3e6b5c91..2e5b27cfccb0 100644 --- a/sw/inc/textboxhelper.hxx +++ b/sw/inc/textboxhelper.hxx @@ -65,8 +65,7 @@ public: /// to the given pObject shape. static void destroy(const SwFrameFormat* pShape, const SdrObject* pObject); /// Get interface of a shape's TextBox, if there is any. -static css::uno::Any queryInterface(const SwFrameFormat* pShape, const css::uno::Type& rType, -SdrObject* pObj); +static css::uno::Any queryInterface(const SwFrameFormat* pShape, const css::uno::Type& rType); /// Sync property of TextBox with the one of the shape. static void syncProperty(SwFrameFormat* pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, @@ -108,9 +107,6 @@ public: /// this function, and returns true in that case too. static std::optional isAnchorTypeDifferent(const SwFrameFormat* pShape); -/// Sets the correct size of textframe depending on the given SdrObject. -static bool syncTextBoxSize(SwFrameFormat* pShape, SdrObject* pObj); - /// Returns true if the given shape has a valid textframe. static bool isTextBoxShapeHasValidTextFrame(const SwFrameFormat* pShape); @@ -181,14 +177,6 @@ public: /// Undo the effect of saveLinks() + individual resetLink() calls. static void restoreLinks(std::set& rOld, std::vector& rNew, SavedLink& rSavedLinks); - -/// Calls the method given by pFunc with every textboxes of the group given by pFormat. -static void synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat*, SdrObject*), -SwFrameFormat* pFormat, SdrObject* pObj); -/// Collect all textboxes of the group given by the pGoupObj Parameter. Returns with a -/// vector filled with the textboxes. -static std::vector CollectTextBoxes(SdrObject* pGroupObject, -SwFrameFormat* pFormat); }; /// Textboxes are basically textframe + shape pairs. This means one shape has one frame. @@ -254,8 +242,6 @@ public: SwFrameFormat* GetOwnerShape() { return m_pOwnerShapeFormat; }; // This will give the current number of textboxes. size_t GetTextBoxCount() const { return m_pTextBoxes.size(); }; -// Returns with a const collection of textboxes owned by this node. -std::map GetAllTextBoxes() const; }; #endif // INCLUDED_SW_INC_TEXTBOXHELPER_HXX diff --git a/sw/qa/uitest/data/ComplexGroupShapeTest.odt b/sw/qa/uitest/data/ComplexGroupShapeTest.odt deleted file mode 100644 index 8fe093203690.. Binary files a/sw/qa/uitest/data/ComplexGroupShapeTest.odt and /dev/null differ diff --git a/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py b/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py deleted file mode 100644 index 7e219d8d7976.. --- a/sw/qa/uitest/writer_tests2/ComplexGroupShapeTest.py +++ /dev/null @@ -1,127 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict -from uitest.uihelper.common import select_pos -from uitest.uihelper.common import
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 12 + sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt |binary sw/qa/core/accessibilitycheck/data/NewlineTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 87 + 5 files changed, 100 insertions(+) New commits: commit 6ea694f14ebdd552be59e50483232415d6c2c067 Author: Paris Oplopoios AuthorDate: Mon Oct 17 12:37:30 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Nov 22 09:52:37 2022 +0100 a11y: Add check for spacing newlines Add accessibility check and relevant test for a document that uses newlines for spacing Change-Id: I14f14db5c51cbad1ee184e58eec8ff28563ba92a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141715 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 858de1a47d93..4d65bd095f51 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -22,6 +22,7 @@ #define STR_AVOID_FOOTNOTES NC_("STR_AVOID_FOOTNOTES", "Avoid footnotes.") #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") +#define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid newlines to create space.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 92a5ea3929e1..c04aadae4d94 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -72,6 +72,18 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckBackgroundImage) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::DOCUMENT_BACKGROUND, aIssues[0]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "NewlineTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(2), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt index 2e319f58e7a2..6b55335e773d 100644 Binary files a/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt and b/sw/qa/core/accessibilitycheck/data/AccessibilityTests1.odt differ diff --git a/sw/qa/core/accessibilitycheck/data/NewlineTest.odt b/sw/qa/core/accessibilitycheck/data/NewlineTest.odt new file mode 100644 index ..9ff715916fc2 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/NewlineTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 0013f6b2eb0e..fdc849e518b6 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -584,6 +584,92 @@ public: } }; +class NewlineSpacingCheck : public NodeCheck +{ +private: +static SwTextNode* getNextTextNode(SwNode* pCurrent) +{ +SwTextNode* pTextNode = nullptr; + +auto nIndex = pCurrent->GetIndex(); +auto nCount = pCurrent->GetNodes().Count(); + +nIndex++; // go to next node + +while (pTextNode == nullptr && nIndex < nCount) +{ +auto pNode = pCurrent->GetNodes()[nIndex]; +if (pNode->IsTextNode()) +pTextNode = pNode->GetTextNode(); +nIndex++; +} + +return pTextNode; +} + +public: +NewlineSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: NodeCheck(rIssueCollection) +{ +} +void check(SwNode* pCurrent) override +{ +if (!pCurrent->IsTextNode()) +return; + +SwTextNode* pTextNode = pCurrent->GetTextNode(); +auto nParagraphLength = pTextNode->GetText().getLength(); +if (nParagraphLength == 0) +{ +SwTextNode* pNextTextNode = getNextTextNode(pCurrent); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 11 +++ sw/qa/core/accessibilitycheck/data/SpaceTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 49 +++ 4 files changed, 61 insertions(+) New commits: commit ef99eca8d474f42343803e7b3828b8ccfd49d9ca Author: offtkp AuthorDate: Wed Oct 12 19:29:28 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Nov 22 09:53:01 2022 +0100 a11y: Add check for spacing spaces Add accessibility check and relevant test for a document that uses multiple spaces for spacing Change-Id: Ib92471c50a25ead28f2b6c7d5e00ed222d4b429e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141267 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141792 Tested-by: Jenkins CollaboraOffice diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 4d65bd095f51..9c45cb84ecd9 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -23,6 +23,7 @@ #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid newlines to create space.") +#define STR_AVOID_SPACES_SPACE NC_("STR_AVOID_SPACES_SPACE", "Avoid spaces to create space.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index c04aadae4d94..46d23380b5df 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -84,6 +84,17 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckNewlineSpace) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckSpacebarSpace) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "SpaceTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(1), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/SpaceTest.odt b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt new file mode 100644 index ..0f00f78f9698 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/SpaceTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index fdc849e518b6..9d5c1164ac63 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -670,6 +670,54 @@ public: } }; +class SpaceSpacingCheck : public NodeCheck +{ +public: +SpaceSpacingCheck(sfx::AccessibilityIssueCollection& rIssueCollection) +: NodeCheck(rIssueCollection) +{ +} +void check(SwNode* pCurrent) override +{ +if (!pCurrent->IsTextNode()) +return; +SwTextNode* pTextNode = pCurrent->GetTextNode(); +auto nParagraphLength = pTextNode->GetText().getLength(); +const OUString& sParagraphText = pTextNode->GetText(); +sal_Int32 nSpaceCount = 0; +sal_Int32 nSpaceStart = 0; +bool bNonSpaceFound = false; +for (sal_Int32 i = 0; i < nParagraphLength; i++) +{ +if (sParagraphText[i] == ' ') +{ +if (bNonSpaceFound) +{ +nSpaceCount++; +if (nSpaceCount == 2) +nSpaceStart = i; +} +} +else +{ +if (nSpaceCount >= 2) +{ +auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_SPACES_SPACE), + sfx::AccessibilityIssueID::TEXT_FORMATTING); +pIssue->setIssueObject(IssueObject::TEXT); +pIssue->setNode(pTextNode); +SwDoc& rDocument = pTextNode->GetDoc(); +pIssue->setDoc(rDocument); +pIssue->setStart(nSpaceStart); +
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/AccessibilityCheckStrings.hrc |1 sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx | 14 +++ sw/qa/core/accessibilitycheck/data/TabsTest.odt |binary sw/source/core/access/AccessibilityCheck.cxx | 68 ++- 4 files changed, 64 insertions(+), 19 deletions(-) New commits: commit b5c36927ad59623ac902fdf0ed80adb0cf49d3e8 Author: Paris Oplopoios AuthorDate: Mon Oct 24 14:12:44 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Tue Nov 22 09:55:07 2022 +0100 a11y: Add check for tabs used for formatting Add accessibility check and relevant test for a document that uses tabs for formatting Useful to detect fake tables made of tabs Change-Id: Ief765f25c8dc67405d0671e257cf0ba7aec9f16c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141732 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142575 Tested-by: Jenkins CollaboraOffice diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 7245a2b8d3e0..baa61cbcb8ba 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -27,6 +27,7 @@ #define STR_AVOID_BACKGROUND_IMAGES NC_("STR_AVOID_BACKGROUND_IMAGES", "Avoid background images.") #define STR_AVOID_NEWLINES_SPACENC_("STR_AVOID_NEWLINES_SPACE", "Avoid newlines to create space.") #define STR_AVOID_SPACES_SPACE NC_("STR_AVOID_SPACES_SPACE", "Avoid spaces to create space.") +#define STR_AVOID_TABS_FORMATTING NC_("STR_AVOID_TABS_FORMATTING", "Avoid using tabs for formatting.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") #define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") diff --git a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx index 122332931544..0059bdf2fa8f 100644 --- a/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx +++ b/sw/qa/core/accessibilitycheck/AccessibilityCheckTest.cxx @@ -152,6 +152,20 @@ CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTableFormatting) CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TABLE_FORMATTING, aIssues[0]->m_eIssueID); } +CPPUNIT_TEST_FIXTURE(AccessibilityCheckTest, testCheckTabsFormatting) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TabsTest.odt"); +CPPUNIT_ASSERT(pDoc); +sw::AccessibilityCheck aCheck(pDoc); +aCheck.check(); +auto& aIssues = aCheck.getIssueCollection().getIssues(); +CPPUNIT_ASSERT_EQUAL(size_t(4), aIssues.size()); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[0]->m_eIssueID); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[1]->m_eIssueID); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[2]->m_eIssueID); +CPPUNIT_ASSERT_EQUAL(sfx::AccessibilityIssueID::TEXT_FORMATTING, aIssues[3]->m_eIssueID); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/accessibilitycheck/data/TabsTest.odt b/sw/qa/core/accessibilitycheck/data/TabsTest.odt new file mode 100644 index ..29b415df87a7 Binary files /dev/null and b/sw/qa/core/accessibilitycheck/data/TabsTest.odt differ diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index d9d1c76e5b67..fc47ce8f39d0 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -771,33 +771,63 @@ public: const OUString& sParagraphText = pTextNode->GetText(); sal_Int32 nSpaceCount = 0; sal_Int32 nSpaceStart = 0; +sal_Int32 nTabCount = 0; bool bNonSpaceFound = false; +bool bPreviousWasChar = false; for (sal_Int32 i = 0; i < nParagraphLength; i++) { -if (sParagraphText[i] == ' ') +switch (sParagraphText[i]) { -if (bNonSpaceFound) +case ' ': { -nSpaceCount++; -if (nSpaceCount == 2) -nSpaceStart = i; +if (bNonSpaceFound) +{ +nSpaceCount++; +if (nSpaceCount == 2) +nSpaceStart = i; +} +break; } -} -else -{ -if (nSpaceCount >= 2) +case '\t': { -auto pIssue = lclAddIssue(m_rIssueCollection, SwResId(STR_AVOID_SPACES_SPAC
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatlinebreak.hxx |2 sw/inc/textlinebreak.hxx |5 + sw/inc/unomap.hxx|4 + sw/inc/unoprnms.hxx |1 sw/qa/core/unocore/unocore.cxx |3 + sw/source/core/txtnode/attrlinebreak.cxx | 30 +- sw/source/core/txtnode/thints.cxx|5 + sw/source/core/unocore/unolinebreak.cxx | 85 ++- sw/source/core/unocore/unomap.cxx|5 + sw/source/core/unocore/unomap1.cxx | 18 ++ 10 files changed, 140 insertions(+), 18 deletions(-) New commits: commit 5feb766541d8817cdab4af5da4c9c40b48771840 Author: Miklos Vajna AuthorDate: Wed Mar 2 09:38:14 2022 +0100 Commit: Miklos Vajna CommitDate: Fri Mar 25 15:46:53 2022 +0100 sw clearing breaks: add UNO API to insert this with custom clear / char props - if (character) properties are specified when the text content itself is inserted, then format the anchor ("dummy") character like that - add the ability to specify a clear type (none/left/right/all) on the line break object itself before insertion (cherry picked from commit 1a240807f2c051ff9a63d713625404a024d7c221) Change-Id: I219a1031e53c2e0368ff329d45b7e3fff0934038 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132107 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatlinebreak.hxx b/sw/inc/formatlinebreak.hxx index 9e26ab11351f..c3a2b0164f86 100644 --- a/sw/inc/formatlinebreak.hxx +++ b/sw/inc/formatlinebreak.hxx @@ -70,7 +70,7 @@ public: void InvalidateLineBreak(); -css::uno::Reference getAnchor(SwDoc& rDoc) const; +css::uno::Reference GetAnchor() const; void SetTextLineBreak(SwTextLineBreak* pTextAttr) { m_pTextAttr = pTextAttr; } diff --git a/sw/inc/textlinebreak.hxx b/sw/inc/textlinebreak.hxx index c0853aa2bd56..33401972f60b 100644 --- a/sw/inc/textlinebreak.hxx +++ b/sw/inc/textlinebreak.hxx @@ -32,11 +32,16 @@ class SwFormatLineBreak; */ class SW_DLLPUBLIC SwTextLineBreak final : public SwTextAttr { +SwTextNode* m_pTextNode; + public: SwTextLineBreak(SwFormatLineBreak& rAttr, sal_Int32 nStart); ~SwTextLineBreak() override; +const SwTextNode& GetTextNode() const; +void SetTextNode(SwTextNode* pNew); + void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index c4c166032983..413adfaf7fc3 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -125,7 +125,8 @@ struct SfxItemPropertyMapEntry; #define PROPERTY_MAP_TABLE_STYLE100 #define PROPERTY_MAP_CELL_STYLE 101 #define PROPERTY_MAP_FIELDMARK 102 -#define PROPERTY_MAP_END103 +#define PROPERTY_MAP_LINEBREAK 103 +#define PROPERTY_MAP_END104 //S&E #define WID_WORDS0 @@ -351,6 +352,7 @@ private: static const SfxItemPropertyMapEntry* GetRedlinePropertyMap(); static const SfxItemPropertyMapEntry* GetRedlinePortionPropertyMap(); static SfxItemPropertyMapEntry* GetTextDefaultPropertyMap(); +static const SfxItemPropertyMapEntry* GetLineBreakPropertyMap(); }; extern SwUnoPropertyMapProvider aSwMapProvider; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 5d8684c47f53..c291742a1641 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -866,6 +866,7 @@ #define UNO_NAME_RESOLVED "Resolved" #define UNO_NAME_ALLOW_OVERLAP "AllowOverlap" +#define UNO_NAME_CLEAR "Clear" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index ddf8d4bb5362..d8c9f9559bd9 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -227,6 +227,9 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakInsert) uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference xLineBreak( xMSF->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY); +uno::Reference xLineBreakProps(xLineBreak, uno::UNO_QUERY); +auto eClear = static_cast(SwLineBreakClear::ALL); +xLineBreakProps->setPropertyValue("Clear", uno::makeAny(eClear)); uno::Reference xText = xTextDocument->getText(); uno::Reference xCursor = xText->createTextCursor(); xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false); diff --git a/sw/source/core/txtnode/attrlinebreak.cxx b/sw/source/core/txtnode/attrlinebreak.cxx index f0f583ecc2df..00d1c275e3dd 100644 --- a/sw/source/core/txtnode/attrlinebreak.cxx +++ b/sw/source/core/txtnode/attrlinebreak.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include using namespace com::sun::star; @@ -74,17 +76,21 @@ void SwFormatLineBreak::InvalidateLineB
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/cmdid.h |1 + sw/inc/formatlinebreak.hxx |1 - sw/inc/textlinebreak.hxx|2 -- sw/inc/unoprnms.hxx |1 + sw/qa/core/unocore/unocore.cxx | 31 +++ sw/source/core/inc/unolinebreak.hxx |3 ++- sw/source/core/inc/unoport.hxx |9 - sw/source/core/unocore/unocoll.cxx |4 ++-- sw/source/core/unocore/unolinebreak.cxx | 26 ++ sw/source/core/unocore/unomap1.cxx |1 + sw/source/core/unocore/unoport.cxx |6 ++ sw/source/core/unocore/unoportenum.cxx | 16 12 files changed, 86 insertions(+), 15 deletions(-) New commits: commit a9975bf6bbeccc69c812135285669ebfe2eea821 Author: Miklos Vajna AuthorDate: Thu Mar 3 12:24:33 2022 +0100 Commit: Miklos Vajna CommitDate: Mon Mar 28 08:45:01 2022 +0200 sw clearing breaks: include this in the UNO API text portion enum Which is how UNO API clients (e.g. ODT export) will be able to read RES_TXTATR_LINEBREAK. (cherry picked from commit a0f86d94e23e8ae0129780745deb2d3526b4fbfa) Conflicts: sw/inc/cmdid.h Change-Id: I44d2058fd8b4a4fefce3dacc49d3bb3da6060756 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132108 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 687f5980d81d..324fa46142ef 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -634,6 +634,7 @@ #define FN_UNO_TRANSFORMED_GRAPHIC (FN_EXTRA2 + 127) #define FN_UNO_GRAPHIC_PREVIEW (FN_EXTRA2 + 128) +#define FN_UNO_LINEBREAK (FN_EXTRA2 + 129) // Area: Help // Region: Traveling & Selection diff --git a/sw/inc/formatlinebreak.hxx b/sw/inc/formatlinebreak.hxx index c3a2b0164f86..f20fa46f78c7 100644 --- a/sw/inc/formatlinebreak.hxx +++ b/sw/inc/formatlinebreak.hxx @@ -23,7 +23,6 @@ #include #include "calbck.hxx" -#include #include #include diff --git a/sw/inc/textlinebreak.hxx b/sw/inc/textlinebreak.hxx index 33401972f60b..5b5e8c6854c3 100644 --- a/sw/inc/textlinebreak.hxx +++ b/sw/inc/textlinebreak.hxx @@ -21,8 +21,6 @@ #include "txatbase.hxx" -#include "ndindex.hxx" - class SwFormatLineBreak; /** diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index c291742a1641..bd1c6e957ac5 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -867,6 +867,7 @@ #define UNO_NAME_RESOLVED "Resolved" #define UNO_NAME_ALLOW_OVERLAP "AllowOverlap" #define UNO_NAME_CLEAR "Clear" +#define UNO_NAME_LINEBREAK "LineBreak" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index d8c9f9559bd9..d971e57d77e3 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -250,6 +250,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakInsert) CPPUNIT_ASSERT_EQUAL(SwLineBreakClear::ALL, rFormatLineBreak.GetValue()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakTextPortionEnum) +{ +// Given a document with a clearing break: +createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xLineBreak( +xMSF->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY); +uno::Reference xLineBreakProps(xLineBreak, uno::UNO_QUERY); +auto eClear = static_cast(SwLineBreakClear::ALL); +xLineBreakProps->setPropertyValue("Clear", uno::makeAny(eClear)); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false); + +// When enumerating the text portions of the only paragraph in the document: +uno::Reference xTextPortion = getRun(getParagraph(1), 1); + +// Then make sure that the text portion type is correct + the clear type can be read: +auto aPortionType = getProperty(xTextPortion, "TextPortionType"); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: LineBreak +// - Actual : Text +// i.e. a line break with properties was part of the normal Text portion, making it impossible +// to get those properties. +CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType); +xLineBreak = getProperty>(xTextPortion, "LineBreak"); +eClear = getProperty(xLineBreak, "Clear"); +CPPUNIT_ASSERT_EQUAL(static_cast(SwLineBreakClear::ALL), eClear); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unolinebreak.hxx b/sw/source/core/inc/unolinebreak.hxx index 1eb939e24b68..0a87753c5e34 100644 --- a/sw/source/core/inc/unolinebreak.hxx +++ b/sw/source/core/inc/unolinebreak.hxx @@ -44,7 +44,8 @@ class SwXLineB
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx | 10 ++ sw/qa/core/crsr/crsr.cxx | 28 sw/source/core/crsr/pam.cxx | 26 ++ sw/source/uibase/wrtsh/wrtsh3.cxx |2 ++ 4 files changed, 66 insertions(+) New commits: commit bca801438f5208b7fbd4402927267958d95ba1d4 Author: Miklos Vajna AuthorDate: Fri Jun 10 08:16:48 2022 +0200 Commit: Miklos Vajna CommitDate: Wed Jun 15 08:13:06 2022 +0200 sw content controls: reject typing inside checkbox or picture content controls Content controls are editable by default (and not only editable, but also capable of hosting rich text content), and Writer doesn't limit the possibility to edit explicitly, either. Certain content control types (checkbox and picture for now) limit the hosted content though: checkbox overwrites the content on click and picture is meant to host a single as-char anchored image. So far the simple implementation Writer didn't enforce these limits, leading the unexpected behavior when clicking on checkbox content controls (possibly not only a checked/non-checked checkmark was toggled, but other content was removed). Fix the problem by making these content control types read-only: this is what also Word does and this way you can't loose the content when you can't enter it earlier. We may want to also do this for dropdowns in the future, once combo boxes will be supported. (cherry picked from commit c321498f915f4e8b3f4853232860ce040ab48e46) Change-Id: I9d44206b3c719a64ec552f2fa0a076901094163e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135821 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 16335c2e0b63..3bb9f6d64489 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -159,6 +159,12 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// Stores a date timestamp, in case the doc model is not yet updated. std::optional m_oSelectedDate; +/** + * E.g. checkbox is read-only by default, but we still update contents on interaction + * internally. This flag is true for the duration of that interaction. + */ +bool m_bReadWrite = false; + public: SwTextContentControl* GetTextAttr() const; @@ -291,6 +297,10 @@ public: void SetColor(const OUString& rColor) { m_aColor = rColor; } OUString GetColor() const { return m_aColor; } + +void SetReadWrite(bool bReadWrite) { m_bReadWrite = bReadWrite; } + +bool GetReadWrite() const { return m_bReadWrite; } }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx index 62cafc6d63a5..7732727cbb3a 100644 --- a/sw/qa/core/crsr/crsr.cxx +++ b/sw/qa/core/crsr/crsr.cxx @@ -136,6 +136,34 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testContentControlLineBreak) CPPUNIT_ASSERT_EQUAL(OUString("t\nest"), pTextNode->GetExpandText(pWrtShell->GetLayout())); } +CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testContentControlReadOnly) +{ +// Given a document with a checkbox content control: +SwDoc* pDoc = createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, u"☐", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +xContentControlProps->setPropertyValue("Checkbox", uno::Any(true)); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// When entering the content control: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +pWrtShell->SttEndDoc(/*bStt=*/true); +pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + +// Then make sure that the cursor is read-only: +// Without the accompanying fix in place, this test would have failed, it was possible to type +// into the checkbox content control, just to loose the typed content on the next click. +CPPUNIT_ASSERT(pWrtShell->HasReadonlySel()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 4add6f1ee201..e376d5042bbb 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -51,6 +51,7 @@ #include #include +#include // for the dump "MSC-" compiler static sal_Int32 GetSttOrEnd( bool bCondition, const
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx |8 ++ sw/inc/unoprnms.hxx |1 sw/qa/core/unocore/unocore.cxx| 33 ++ sw/source/core/txtnode/attrcontentcontrol.cxx |2 + sw/source/core/unocore/unocontentcontrol.cxx | 29 ++ sw/source/core/unocore/unomap1.cxx|1 sw/source/uibase/wrtsh/wrtsh1.cxx |1 7 files changed, 75 insertions(+) New commits: commit ff09dd0bdcd64503c15f4b9ee4cdf6238426437c Author: Miklos Vajna AuthorDate: Wed Jul 20 14:42:55 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Jul 26 16:50:32 2022 +0200 sw content controls, plain text: add doc model & UNO API OOXML's with describes a plain text content control. We are currently mapping this to fields, and then on export it's possible to map this to FORMTEXT fields. The trouble is that our doc model could not differentiate between content controls and fields for non-formatted form text, so the exporter can't do the opposite of import. This has the benefit that input fields do a reasonable job of providing the feature set of plain text content controls, but it has the downside that we map two OOXML features to a single Writer concept, loosing formatting. Fix this by introducing a dedicated "plain text" content control type, which can be used for OOXML's with , and keep using the input field only for OOXML fields. This commit just adds the document model & UNO API, follow-up commits will add the remaining functionality. (cherry picked from commit da8e95ebe0dce032cfbe37602ebb013869dc1e6d) Conflicts: sw/qa/core/unocore/unocore.cxx Change-Id: I0a0317adbd5f58c6ab880dccf6170292462d2671 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137470 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index b40c9cdba0d7..6c1dffd240ae 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -44,6 +44,7 @@ enum class SwContentControlType DROP_DOWN_LIST, PICTURE, DATE, +PLAIN_TEXT, }; /// SfxPoolItem subclass that wraps an SwContentControl. @@ -142,6 +143,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// Date in -MM-DDT00:00:00Z format. OUString m_aCurrentDate; +/// Plain text, i.e. not rich text. +bool m_bPlainText = false; + /// The placeholder's doc part: just remembered. OUString m_aPlaceholderDocPart; @@ -257,6 +261,10 @@ public: /// Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into account. OUString GetDateString() const; +void SetPlainText(bool bPlainText) { m_bPlainText = bPlainText; } + +bool GetPlainText() const { return m_bPlainText; } + void SetPlaceholderDocPart(const OUString& rPlaceholderDocPart) { m_aPlaceholderDocPart = rPlaceholderDocPart; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 1ac7b671c695..f31523e73d3e 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -880,6 +880,7 @@ #define UNO_NAME_DATE_FORMAT "DateFormat" #define UNO_NAME_DATE_LANGUAGE "DateLanguage" #define UNO_NAME_CURRENT_DATE "CurrentDate" +#define UNO_NAME_PLAIN_TEXT "PlainText" #define UNO_NAME_PLACEHOLDER_DOC_PART "PlaceholderDocPart" #define UNO_NAME_DATA_BINDING_PREFIX_MAPPINGS "DataBindingPrefixMappings" #define UNO_NAME_DATA_BINDING_XPATH "DataBindingXpath" diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index e7fd560b4370..daf34fb89a73 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -587,6 +587,39 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) CPPUNIT_ASSERT_EQUAL(OUString("008000"), pContentControl->GetColor()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPlainText) +{ +// Given an empty document: +SwDoc* pDoc = createSwDoc(); + +// When inserting a plain text content control around a text portion: +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +xContentControlProps->setPropertyValue("PlainText", uno::Any(true)); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// Then make sure that the text attribute is inserte
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx | 14 +++ sw/inc/textcontentcontrol.hxx |2 sw/inc/txatbase.hxx | 10 ++ sw/inc/unomap.hxx |4 - sw/inc/unoprnms.hxx |1 sw/qa/core/unocore/unocore.cxx|9 ++ sw/source/core/inc/unocontentcontrol.hxx | 21 + sw/source/core/txtnode/attrcontentcontrol.cxx | 36 + sw/source/core/txtnode/txatbase.cxx |1 sw/source/core/unocore/unocontentcontrol.cxx | 95 ++ sw/source/core/unocore/unomap.cxx |5 + sw/source/core/unocore/unomap1.cxx| 17 12 files changed, 212 insertions(+), 3 deletions(-) New commits: commit 9be61b4d6b246a239e22bdbd5f97c5ad44fe80da Author: Miklos Vajna AuthorDate: Fri Apr 1 10:58:01 2022 +0200 Commit: Miklos Vajna CommitDate: Thu Apr 21 08:08:08 2022 +0200 sw content controls: add UNO API to insert this with custom props Add the ability to specify if the content control is a placeholder or not on the content control object itself before insertion. (cherry picked from commit 5da08b21cd23f2e70f5003733b03a7aee7915225) Change-Id: Ia06869c69a5b85cfc1d0a55739bbb23a53bef4d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132962 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 0fa075bf7036..c1ac07279efe 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -61,6 +61,8 @@ public: void NotifyChangeTextNode(SwTextNode* pTextNode); static SwFormatContentControl* CreatePoolDefault(sal_uInt16 nWhich); SwContentControl* GetContentControl() { return m_pContentControl.get(); } + +void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; /// Stores the properties of a content control. @@ -73,6 +75,9 @@ class SwContentControl : public sw::BroadcastingModify /// Can be nullptr if not in a document for undo purposes. SwTextNode* m_pTextNode; +/// Current content is placeholder text. +bool m_bShowingPlaceHolder = false; + public: SwTextContentControl* GetTextAttr() const; @@ -99,6 +104,15 @@ public: explicit SwContentControl(SwFormatContentControl* pFormat); virtual ~SwContentControl() override; + +void SetShowingPlaceHolder(bool bShowingPlaceHolder) +{ +m_bShowingPlaceHolder = bShowingPlaceHolder; +} + +bool GetShowingPlaceHolder() const { return m_bShowingPlaceHolder; } + +virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/textcontentcontrol.hxx b/sw/inc/textcontentcontrol.hxx index 3410a6a35506..1c445d812099 100644 --- a/sw/inc/textcontentcontrol.hxx +++ b/sw/inc/textcontentcontrol.hxx @@ -36,6 +36,8 @@ public: ~SwTextContentControl() override; void ChgTextNode(SwTextNode* pNode); + +void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 110e12064c9c..183e254f8817 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -29,6 +29,7 @@ #include "fmtflcnt.hxx" #include "fmtftn.hxx" #include "formatlinebreak.hxx" +#include "formatcontentcontrol.hxx" #include "fchrfmt.hxx" #include "tox.hxx" #include "ndhints.hxx" @@ -39,7 +40,7 @@ class SfxItemPool; * A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an * optional end. */ -class SAL_DLLPUBLIC_RTTI SwTextAttr +class SW_DLLPUBLIC SwTextAttr { friend class SwpHints; private: @@ -121,6 +122,7 @@ public: inline const SwFormatField &GetFormatField() const; inline const SwFormatFootnote &GetFootnote() const; inline const SwFormatLineBreak& GetLineBreak() const; +inline const SwFormatContentControl& GetContentControl() const; inline const SwFormatFlyCnt&GetFlyCnt() const; inline const SwTOXMark &GetTOXMark() const; inline const SwFormatRefMark &GetRefMark() const; @@ -215,6 +217,12 @@ inline const SwFormatLineBreak& SwTextAttr::GetLineBreak() const return static_cast(*m_pAttr); } +inline const SwFormatContentControl& SwTextAttr::GetContentControl() const +{ +assert(m_pAttr && m_pAttr->Which() == RES_TXTATR_CONTENTCONTROL); +return static_cast(*m_pAttr); +} + inline const SwFormatFlyCnt& SwTextAttr::GetFlyCnt() const { assert( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT ); diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index 413adfaf7fc3..ac31474a92d6 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -126,7 +126,8 @@ struct SfxItemPropertyMapEntry; #define PROPERTY_MAP_CELL_STYLE 101 #define
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/cmdid.h |1 sw/inc/unoprnms.hxx|1 sw/qa/core/unocore/unocore.cxx | 35 ++ sw/source/core/inc/unoport.hxx |9 + sw/source/core/unocore/unomap1.cxx |1 sw/source/core/unocore/unoport.cxx |6 +++ sw/source/core/unocore/unoportenum.cxx | 52 - 7 files changed, 103 insertions(+), 2 deletions(-) New commits: commit ac13e1d935080c94fccddab333bba11245716f10 Author: Miklos Vajna AuthorDate: Mon Apr 4 08:23:06 2022 +0200 Commit: Miklos Vajna CommitDate: Thu Apr 21 08:08:22 2022 +0200 sw content controls: include this in the UNO API text portion enum Which is how UNO API clients (e.g. ODT export) will be able to read RES_TXTATR_CONTENTCONTROL. (cherry picked from commit cb35526e9221d9781abb3cee2ba6971736b6b333) Conflicts: sw/inc/cmdid.h sw/qa/core/unocore/unocore.cxx Change-Id: Idf87312b1b89a0e44e7de2578de44b263fa8689a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133221 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 324fa46142ef..afe61b164849 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -635,6 +635,7 @@ #define FN_UNO_TRANSFORMED_GRAPHIC (FN_EXTRA2 + 127) #define FN_UNO_GRAPHIC_PREVIEW (FN_EXTRA2 + 128) #define FN_UNO_LINEBREAK (FN_EXTRA2 + 129) +#define FN_UNO_CONTENT_CONTROL (FN_EXTRA2 + 130) // Area: Help // Region: Traveling & Selection diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index eed4a67fab61..79a64e4109f5 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -869,6 +869,7 @@ #define UNO_NAME_ALLOW_OVERLAP "AllowOverlap" #define UNO_NAME_CLEAR "Clear" #define UNO_NAME_LINEBREAK "LineBreak" +#define UNO_NAME_CONTENT_CONTROL "ContentControl" #define UNO_NAME_SHOWING_PLACE_HOLDER "ShowingPlaceHolder" #endif diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index b079354a1f30..4f9479a673d1 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -318,6 +318,41 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlInsert) CPPUNIT_ASSERT(pContentControl->GetShowingPlaceHolder()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlTextPortionEnum) +{ +// Given a document with a content control around one or more text portions: +createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// When enumerating the text portions of the only paragraph in the document: +uno::Reference xTextPortion = getRun(getParagraph(1), 1); + +// Then make sure that the text portion type is correct + the content can be read: +auto aPortionType = getProperty(xTextPortion, "TextPortionType"); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: ContentControl +// - Actual : Text +// i.e. the content control text attribute was ignored. +CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType); +xContentControl += getProperty>(xTextPortion, "ContentControl"); +uno::Reference xContentControlRange(xContentControl, uno::UNO_QUERY); +xText = xContentControlRange->getText(); +uno::Reference xContentEnumAccess(xText, uno::UNO_QUERY); +uno::Reference xContentEnum = xContentEnumAccess->createEnumeration(); +uno::Reference xContent(xContentEnum->nextElement(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("test"), xContent->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx index 76cf877db70b..936bc01e0521 100644 --- a/sw/source/core/inc/unoport.hxx +++ b/sw/source/core/inc/unoport.hxx @@ -75,7 +75,8 @@ enum SwTextPortionType PORTION_FIELD_START_END, PORTION_ANNOTATION, PORTION_ANNOTATION_END, -PORTION_LINEBREAK +PORTION_LINEBREAK, +PORTION_CONTENT_CONTROL }; class SwXTextPortion : public cppu::WeakImplHelper @@ -109,6 +110,7 @@ private: css::uno::Reference< css::text::XTextContent > m_xMeta; css::uno::Reference m_xLineBreak; +css::uno::Reference m_xContentControl; std::unique_ptr< css::uno::Any > m_pRubyText; std::unique_ptr< css::uno::A
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/crsrsh.hxx |5 +- sw/inc/formatcontentcontrol.hxx |1 sw/qa/uibase/wrtsh/wrtsh.cxx | 39 ++ sw/source/core/crsr/crstrvl.cxx | 54 ++ sw/source/core/txtnode/attrcontentcontrol.cxx |4 + sw/source/core/txtnode/txatbase.cxx |2 sw/source/uibase/docvw/edtwin.cxx | 13 +- sw/source/uibase/inc/wrtsh.hxx|3 + sw/source/uibase/wrtsh/wrtsh3.cxx | 20 + 9 files changed, 139 insertions(+), 2 deletions(-) New commits: commit a11754d55024d55574d227a1c1c3e9e1c6124d54 Author: Miklos Vajna AuthorDate: Thu Apr 7 09:11:09 2022 +0200 Commit: Miklos Vajna CommitDate: Fri Apr 22 08:31:42 2022 +0200 sw content controls: select the content on click when showing placeholder - teach SwCursorShell::GetContentAtPos() about a new IsAttrAtPos::ContentControl - add a new SwCursorShell::GotoFormatContentControl() to select a content control, and a SwWrtShell::GotoContentControl() wrapper around it - combine these together in SwEditWin::MouseButtonUp() The intention is that when you open a document and you click on a placeholder text like "Click here to enter text", then this content is pre-selected (so typing overwrites it), but typing real content there disables this behavior. (cherry picked from commit 07a1442b2441cc032c05fd9abf5b1a8db6c7e007) Change-Id: Ia539865da7b18c41cbfb398282842bdb2e25f0bc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133245 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 6d843e7e424d..a34e02d45ead 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -89,9 +89,10 @@ enum class IsAttrAtPos ,CurrAttrs = 0x4000///< only for debugging ,TableBoxValue = 0x8000///< only for debugging #endif +, ContentControl = 0x1 }; namespace o3tl { -template<> struct typed_flags : is_typed_flags {}; +template<> struct typed_flags : is_typed_flags {}; } struct SwContentAtPos @@ -703,6 +704,8 @@ public: bool GotoFormatField( const SwFormatField& rField ); +bool GotoFormatContentControl(const SwFormatContentControl& rContentControl); + static SwTextField* GetTextFieldAtPos( const SwPosition* pPos, const bool bIncludeInputFieldAtStart ); diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index c1ac07279efe..d50c68945f39 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -61,6 +61,7 @@ public: void NotifyChangeTextNode(SwTextNode* pTextNode); static SwFormatContentControl* CreatePoolDefault(sal_uInt16 nWhich); SwContentControl* GetContentControl() { return m_pContentControl.get(); } +const SwContentControl* GetContentControl() const { return m_pContentControl.get(); } void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 9f63ed2fc7e6..d73ba55ef09f 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -21,6 +22,8 @@ #include #include #include +#include +#include namespace { @@ -51,6 +54,42 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertLineBreak) auto eClear = getProperty(xLineBreak, "Clear"); CPPUNIT_ASSERT_EQUAL(static_cast(SwLineBreakClear::ALL), eClear); } + +CPPUNIT_TEST_FIXTURE(Test, testGotoContentControl) +{ +// Given a document with a content control: +SwDoc* pDoc = createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +xContentControlProps->setPropertyValue("ShowingPlaceHolder", uno::makeAny(true)); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// When going to that content control in placeholder mode: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); +SwTextNode* pTextNode = pDoc->GetNodes()[nIndex]->GetTextNode(); +SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); +auto pTextContentControl = static_txtattr_cast(pAttr); +auto& rFormatCon
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx | 26 + sw/inc/unoprnms.hxx |1 sw/qa/core/unocore/unocore.cxx| 51 +++ sw/source/core/txtnode/attrcontentcontrol.cxx | 69 ++ sw/source/core/unocore/unocontentcontrol.cxx | 30 ++- sw/source/core/unocore/unomap1.cxx|1 sw/source/uibase/wrtsh/wrtsh1.cxx |1 7 files changed, 178 insertions(+), 1 deletion(-) New commits: commit 63bb6cc38f14fec79a241d7c313b1a7aea63637b Author: Miklos Vajna AuthorDate: Tue May 3 09:44:01 2022 +0200 Commit: Miklos Vajna CommitDate: Mon May 9 08:25:49 2022 +0200 sw content controls, drop-down: add doc model & UNO API Add a new property, which is a list of display-text / value pairs. If the list is non-empty, that implies that the type is a dropdown. This should be enough for the UI to be able to provide a list of choices & update dropdown state on click. Note that in contrast to dropdown field-marks, here each entry has a user-readable string and a machine-readable value. Fieldmarks only had a single value. (cherry picked from commit 0a415b92d3c1ea2c5befd30b4ac29442f422a41d) Change-Id: I22b9f554e2e1a9e84cc7eb7e17772ea1a5775316 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133944 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 43309f49f55c..f646e28b16f5 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -20,6 +20,7 @@ #pragma once #include +#include #include #include @@ -35,6 +36,7 @@ enum class SwContentControlType { RICH_TEXT, CHECKBOX, +DROP_DOWN_LIST, }; /// SfxPoolItem subclass that wraps an SwContentControl. @@ -72,6 +74,21 @@ public: void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; +/// Represents one list item in a content control dropdown list. +class SwContentControlListItem +{ +public: +OUString m_aDisplayText; +OUString m_aValue; + +void dumpAsXml(xmlTextWriterPtr pWriter) const; + +static void ItemsToAny(const std::vector& rItems, + css::uno::Any& rVal); + +static std::vector ItemsFromAny(const css::uno::Any& rVal); +}; + /// Stores the properties of a content control. class SwContentControl : public sw::BroadcastingModify { @@ -97,6 +114,8 @@ class SwContentControl : public sw::BroadcastingModify /// If m_bCheckbox is true, the value of an unchecked checkbox. OUString m_aUncheckedState; +std::vector m_aListItems; + public: SwTextContentControl* GetTextAttr() const; @@ -147,6 +166,13 @@ public: OUString GetUncheckedState() const { return m_aUncheckedState; } +std::vector GetListItems() const { return m_aListItems; } + +void SetListItems(const std::vector& rListItems) +{ +m_aListItems = rListItems; +} + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 239ab6a56a97..7a3b592a4858 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -875,6 +875,7 @@ #define UNO_NAME_CHECKED "Checked" #define UNO_NAME_CHECKED_STATE "CheckedState" #define UNO_NAME_UNCHECKED_STATE "UncheckedState" +#define UNO_NAME_LIST_ITEMS "ListItems" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 0e3fcc9ef7c0..40fe6c31329b 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -403,6 +403,57 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlCheckbox) CPPUNIT_ASSERT_EQUAL(OUString(u"☐"), pContentControl->GetUncheckedState()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDropdown) +{ +// Given an empty document: +SwDoc* pDoc = createSwDoc(); + +// When inserting a dropdown content control: +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +{ +uno::Sequence aListItems = { +{ +comphelper::makePropertyValue("DisplayText", uno::makeAny(OUString("red"))), +comphelper::makePropertyValue("Value", uno::makeAny(OUString("R"))), +}, +{ +comphelper::makePropertyValue("D
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx | 10 +++ sw/qa/uibase/wrtsh/wrtsh.cxx | 53 +++ sw/source/core/crsr/crstrvl.cxx |3 - sw/source/core/crsr/dropdowncontentcontrolbutton.cxx | 10 ++- sw/source/core/crsr/viscrs.cxx | 13 +++- sw/source/core/inc/contentcontrolbutton.hxx |2 sw/source/uibase/wrtsh/wrtsh3.cxx| 27 + 7 files changed, 111 insertions(+), 7 deletions(-) New commits: commit acacd1f33917d6da8f8801b26396e3831ae4057a Author: Miklos Vajna AuthorDate: Fri May 6 13:48:46 2022 +0200 Commit: Miklos Vajna CommitDate: Mon May 9 08:30:39 2022 +0200 sw content controls, drop-down: select list item on click - remember the selected list item in SwDropDownContentControlButton::ListBoxHandler() - extend SwWrtShell::GotoContentControl() to update the document text, somewhat similar to how checkboxes are already handled - improve SwSelPaintRects::HighlightContentControl(): - re-create the vcl widget in case a different content control was selected - adjust position/size and re-show the dropdown button after selecting an item + doc text was updated (cherry picked from commit 9ca44e925a8e06e0946fa9e7bd80cfdbfbb83c62) Change-Id: Id3b89b6132697bfec7046caeb1f0c5fe93e99b37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133947 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index f7299028436a..a7bf74681936 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -116,6 +116,9 @@ class SwContentControl : public sw::BroadcastingModify std::vector m_aListItems; +/// Stores a list item index, in case the doc model is not yet updated. +std::optional m_oSelectedListItem; + public: SwTextContentControl* GetTextAttr() const; @@ -175,6 +178,13 @@ public: m_aListItems = rListItems; } +void SetSelectedListItem(std::optional oSelectedListItem) +{ +m_oSelectedListItem = oSelectedListItem; +} + +std::optional GetSelectedListItem() const { return m_oSelectedListItem; } + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/sw/qa/uibase/wrtsh/wrtsh.cxx b/sw/qa/uibase/wrtsh/wrtsh.cxx index 5fddff1d884f..1e2ef1bb48bd 100644 --- a/sw/qa/uibase/wrtsh/wrtsh.cxx +++ b/sw/qa/uibase/wrtsh/wrtsh.cxx @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -165,6 +166,58 @@ CPPUNIT_TEST_FIXTURE(Test, testInsertCheckboxContentControl) // control wasn't a checkbox one. CPPUNIT_ASSERT(pContentControl->GetCheckbox()); } + +CPPUNIT_TEST_FIXTURE(Test, testSelectDropdownContentControl) +{ +// Given a document with a dropdown content control: +SwDoc* pDoc = createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "choose an item", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +{ +uno::Sequence aListItems = { +{ +comphelper::makePropertyValue("DisplayText", uno::Any(OUString("red"))), +comphelper::makePropertyValue("Value", uno::Any(OUString("R"))), +}, +{ +comphelper::makePropertyValue("DisplayText", uno::Any(OUString("green"))), +comphelper::makePropertyValue("Value", uno::Any(OUString("G"))), +}, +{ +comphelper::makePropertyValue("DisplayText", uno::Any(OUString("blue"))), +comphelper::makePropertyValue("Value", uno::Any(OUString("B"))), +}, +}; +xContentControlProps->setPropertyValue("ListItems", uno::Any(aListItems)); +} +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// When clicking on that content control: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode(); +SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); +auto pTextContentControl = static_txtattr_cast(pAttr); +auto& rFormatContentControl += static_cast(pTextContentControl->GetAttr()); +rFormatContentControl.GetContentControl()->SetSelectedListItem(0); +pWrtShell->GotoContentControl(rFormatContentCon
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/crsrsh.hxx |1 sw/inc/ndtxt.hxx|8 sw/qa/core/crsr/crsr.cxx| 32 sw/qa/core/doc/doc.cxx | 30 +++ sw/qa/core/unocore/unocore.cxx | 27 + sw/qa/extras/ww8export/ww8export2.cxx | 28 ++ sw/qa/inc/swmodeltestbase.hxx |2 + sw/qa/unit/swmodeltestbase.cxx | 21 ++ sw/source/core/crsr/crstrvl.cxx | 21 ++ sw/source/core/doc/DocumentContentOperationsManager.cxx | 12 +- sw/source/core/txtnode/ndtxt.cxx| 22 +++ sw/source/core/unocore/unocrsrhelper.cxx|9 sw/source/filter/ww8/wrtw8nds.cxx |7 +++ sw/source/uibase/docvw/edtwin.cxx |3 + sw/source/uibase/shells/textsh.cxx |2 - 15 files changed, 222 insertions(+), 3 deletions(-) New commits: commit f3c0701fc10ac03bf6335cd5ae9ce5f90abf5d21 Author: Miklos Vajna AuthorDate: Thu May 12 16:31:53 2022 +0200 Commit: Miklos Vajna CommitDate: Fri May 13 13:21:28 2022 +0200 sw content controls: fixes for the ending dummy char - make sure the DOC/RTF export doesn't write the dummy char as-is - let "enter" only insert a linebreak while inside a content control, to ensure that the starting and ending dummy char stays inside the same text node - let deletion of the dummy character at the end behave the same as the start dummy character: if trying to delete that single character, then just move the cursor, don't delete it - reject document insertion in the middle of a content control, similar to input fields (cherry picked from commit 32dab3228cd315437efe0c5b850d116235eaa797) Conflicts: sw/qa/core/unocore/unocore.cxx sw/source/core/unocore/unocrsrhelper.cxx Change-Id: I9b54ef50261e6b17f38eadadacfe1e199e96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134261 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index a34e02d45ead..2dd27529810a 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -717,6 +717,7 @@ public: const bool bIncludeInputFieldAtStart ); SwField* GetCurField( const bool bIncludeInputFieldAtStart = false ) const; bool CursorInsideInputField() const; +bool CursorInsideContentControl() const; static bool PosInsideInputField( const SwPosition& rPos ); bool DocPtInsideInputField( const Point& rDocPt ) const; static sal_Int32 StartOfInputFieldAtPos( const SwPosition& rPos ); diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index c77e062d80cd..9e83ded061f6 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -403,6 +403,14 @@ public: const sal_Int32 nIndex, const sal_uInt16 nWhich = RES_TXTATR_END ) const; +/** + * Get the text attribute of an end dummy character at nIndex. Return the attribute only in + * case its which id is nWhich. + * + * Note that the position of the end dummy character is one less than the end of the attribute. + */ +SwTextAttr* GetTextAttrForEndCharAt(sal_Int32 nIndex, sal_uInt16 nWhich) const; + SwTextField* GetFieldTextAttrAt( const sal_Int32 nIndex, const bool bIncludeInputFieldAtStart = false ) const; diff --git a/sw/qa/core/crsr/crsr.cxx b/sw/qa/core/crsr/crsr.cxx index 0b93fcc43522..62cafc6d63a5 100644 --- a/sw/qa/core/crsr/crsr.cxx +++ b/sw/qa/core/crsr/crsr.cxx @@ -23,6 +23,7 @@ #include #include #include +#include constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/core/crsr/data/"; @@ -104,6 +105,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testSelAllStartsWithTable) CPPUNIT_ASSERT_EQUAL(static_cast(0), pDoc->GetTableFrameFormatCount(/*bUsed=*/true)); } +CPPUNIT_TEST_FIXTURE(SwCoreCrsrTest, testContentControlLineBreak) +{ +// Given a document with a (rich text) content control: +SwDoc* pDoc = createSwDoc(); +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// When pressing "enter" in the middle of that content control: +SwWrtShell* pWrtShell = pDoc-
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx |7 + sw/inc/unoprnms.hxx |1 sw/qa/core/unocore/unocore.cxx| 32 ++ sw/source/core/txtnode/attrcontentcontrol.cxx |2 + sw/source/core/unocore/unocontentcontrol.cxx | 29 +++ sw/source/core/unocore/unolinebreak.cxx |1 sw/source/core/unocore/unomap1.cxx|1 sw/source/uibase/wrtsh/wrtsh1.cxx |1 8 files changed, 74 insertions(+) New commits: commit 668412021ba877601ed22c29f615f4a15a6a3887 Author: Miklos Vajna AuthorDate: Tue May 17 08:18:34 2022 +0200 Commit: Miklos Vajna CommitDate: Fri May 20 11:32:23 2022 +0200 sw content controls, picture: add doc model & UNO API This is meant to be a content control (providing rich text), which is also a picture placeholder field. Add a new Picture property to track this type, this way the click handler will be able to present a file picker when showing the placeholder. (cherry picked from commit 0f25676a07131b60f5ff7881b39379c33b3e9f54) Change-Id: Ibbd3720fc94d0f17654ec813821d218166c76424 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134662 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 7304a48214a9..2c438715ee32 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -38,6 +38,7 @@ enum class SwContentControlType RICH_TEXT, CHECKBOX, DROP_DOWN_LIST, +PICTURE, }; /// SfxPoolItem subclass that wraps an SwContentControl. @@ -123,6 +124,8 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify std::vector m_aListItems; +bool m_bPicture = false; + /// Stores a list item index, in case the doc model is not yet updated. std::optional m_oSelectedListItem; @@ -185,6 +188,10 @@ public: m_aListItems = rListItems; } +void SetPicture(bool bPicture) { m_bPicture = bPicture; } + +bool GetPicture() const { return m_bPicture; } + void SetSelectedListItem(std::optional oSelectedListItem) { m_oSelectedListItem = oSelectedListItem; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 7a3b592a4858..a20b345d6640 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -876,6 +876,7 @@ #define UNO_NAME_CHECKED_STATE "CheckedState" #define UNO_NAME_UNCHECKED_STATE "UncheckedState" #define UNO_NAME_LIST_ITEMS "ListItems" +#define UNO_NAME_PICTURE "Picture" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 1e663a7bb156..fec19e7abefe 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -491,6 +491,38 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testInsertFileInContentControlException) xInsertable->insertDocumentFromURL(aURL, {}); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPicture) +{ +// Given an empty document: +SwDoc* pDoc = createSwDoc(); + +// When inserting a picture content control: +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertString(xCursor, "test", /*bAbsorb=*/false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +// Without the accompanying fix in place, this test would have failed with: +// An uncaught exception of type com.sun.star.beans.UnknownPropertyException +xContentControlProps->setPropertyValue("Picture", uno::Any(true)); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); + +// Then make sure that the specified properties are set: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +SwTextNode* pTextNode = pWrtShell->GetCursor()->GetNode().GetTextNode(); +SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_CONTENTCONTROL); +auto pTextContentControl = static_txtattr_cast(pAttr); +auto& rFormatContentControl += static_cast(pTextContentControl->GetAttr()); +std::shared_ptr pContentControl = rFormatContentControl.GetContentControl(); +CPPUNIT_ASSERT(pContentControl->GetPicture()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/attrcontentcontrol.cxx b/sw/source/core/txtnode/attrcontentcontrol.cxx index c249adffd819..24e50d5b72af 100644 --- a/sw/source/core/txtnode/attrcontentcont
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/formatcontentcontrol.hxx | 19 + sw/inc/unoprnms.hxx |2 sw/qa/core/unocore/unocore.cxx| 41 sw/source/core/txtnode/attrcontentcontrol.cxx |6 + sw/source/core/unocore/unocontentcontrol.cxx | 85 ++ sw/source/core/unocore/unomap1.cxx|3 sw/source/uibase/wrtsh/wrtsh1.cxx |1 7 files changed, 157 insertions(+) New commits: commit b95278f71ed3ca27f5ef370e11f6a30b87148d5c Author: Miklos Vajna AuthorDate: Tue May 24 08:16:57 2022 +0200 Commit: Miklos Vajna CommitDate: Mon May 30 14:25:26 2022 +0200 sw content controls, date: add doc model & UNO API This is meant to be a content control (providing rich text), which also has a dropdown-like date picker button. Add a new Date property to track this type, together with date format and date language. This should be enough for the UI to generate a correct date string when the file picker is used. (cherry picked from commit af353743dfe161e5289a7786a46bf3e8b1de43e3) Change-Id: If5d46a804d771e903a688fd73cfaf2d2809b7ab9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135115 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index 2c438715ee32..b4737c71ae90 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -39,6 +39,7 @@ enum class SwContentControlType CHECKBOX, DROP_DOWN_LIST, PICTURE, +DATE, }; /// SfxPoolItem subclass that wraps an SwContentControl. @@ -126,6 +127,12 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify bool m_bPicture = false; +bool m_bDate = false; + +OUString m_aDateFormat; + +OUString m_aDateLanguage; + /// Stores a list item index, in case the doc model is not yet updated. std::optional m_oSelectedListItem; @@ -192,6 +199,18 @@ public: bool GetPicture() const { return m_bPicture; } +void SetDate(bool bDate) { m_bDate = bDate; } + +bool GetDate() const { return m_bDate; } + +void SetDateFormat(const OUString& rDateFormat) { m_aDateFormat = rDateFormat; } + +OUString GetDateFormat() const { return m_aDateFormat; } + +void SetDateLanguage(const OUString& rDateLanguage) { m_aDateLanguage = rDateLanguage; } + +OUString GetDateLanguage() const { return m_aDateLanguage; } + void SetSelectedListItem(std::optional oSelectedListItem) { m_oSelectedListItem = oSelectedListItem; diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index a20b345d6640..4ac4aa7d0dca 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -877,6 +877,8 @@ #define UNO_NAME_UNCHECKED_STATE "UncheckedState" #define UNO_NAME_LIST_ITEMS "ListItems" #define UNO_NAME_PICTURE "Picture" +#define UNO_NAME_DATE_FORMAT "DateFormat" +#define UNO_NAME_DATE_LANGUAGE "DateLanguage" #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 83d2698b3353..998c4d285adc 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -528,6 +528,47 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlPicture) CPPUNIT_ASSERT(pContentControl->GetPicture()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) +{ +// Given an empty document: +SwDoc* pDoc = createSwDoc(); + +// When inserting a date content control: +uno::Reference xMSF(mxComponent, uno::UNO_QUERY); +uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); +uno::Reference xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +uno::Reference xTextGraphic( +xMSF->createInstance("com.sun.star.text.TextGraphicObject"), uno::UNO_QUERY); +xTextGraphic->setPropertyValue("AnchorType", + uno::Any(text::TextContentAnchorType_AS_CHARACTER)); +uno::Reference xTextContent(xTextGraphic, uno::UNO_QUERY); +xText->insertTextContent(xCursor, xTextContent, false); +xCursor->gotoStart(/*bExpand=*/false); +xCursor->gotoEnd(/*bExpand=*/true); +uno::Reference xContentControl( +xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY); +uno::Reference xContentControlProps(xContentControl, uno::UNO_QUERY); +// Without the accompanying fix in place, this test would have failed with: +// An uncaught exception of type com.sun.star.beans.UnknownPropertyException +xContentControlProps->setPropertyValue("Date", uno::Any(true)); +xContentControlProps->setPropertyValue("DateFormat", uno::Any(OUString("M/d/"))); +xContentControlProps->setPropertyValue("DateLanguage", uno::Any(OUString("en-US"))); +xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/swmodule.hxx|1 sw/qa/extras/tiledrendering/tiledrendering.cxx | 370 ++--- sw/source/uibase/app/swmodul1.cxx |5 3 files changed, 102 insertions(+), 274 deletions(-) New commits: commit 3acc12203e1edecfeac565807acc6826311f79fe Author: Miklos Vajna AuthorDate: Wed Jun 1 11:28:49 2022 +0200 Commit: Miklos Vajna CommitDate: Fri Jun 3 13:35:49 2022 +0200 CppunitTest_sw_tiledrendering: use CPPUNIT_TEST_FIXTURE() Which changes the order of the tests in the suite, so testRedlineColors runs later and the global list of redline authors now contains unexpected entries, leading to an assertion failure. Fix this by clearing the redline author list at the start of each test. (cherry picked from commit 2de53e222fa9126422ff69dde3c585349958d494) Change-Id: Ifffe079eb83cd3184c962ea2e69505bd518a52bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135330 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx index c5ea28017b41..c1c267e4a0a9 100644 --- a/sw/inc/swmodule.hxx +++ b/sw/inc/swmodule.hxx @@ -199,6 +199,7 @@ public: // Redlining. std::size_t GetRedlineAuthor(); OUString const &GetRedlineAuthor(std::size_t nPos); +void ClearRedlineAuthors(); /// See SwXTextDocument::getTrackedChangeAuthors(). voidGetRedlineAuthorInfo(tools::JsonWriter& rJsonWriter); std::size_t InsertRedlineAuthor(const OUString& rAuthor); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index bdcaf03c55a7..80125d1c31d5 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -68,6 +68,8 @@ #include #include #include +#include +#include constexpr OUStringLiteral DATA_DIRECTORY = u"/sw/qa/extras/tiledrendering/data/"; @@ -84,189 +86,8 @@ public: SwTiledRenderingTest(); virtual void setUp() override; virtual void tearDown() override; -void testRegisterCallback(); -void testPostKeyEvent(); -void testPostMouseEvent(); -void testSetTextSelection(); -void testGetTextSelection(); -void testGetTextSelectionLineLimit(); -void testSetGraphicSelection(); -void testResetSelection(); -void testInsertShape(); -void testSearch(); -void testSearchViewArea(); -void testSearchTextFrame(); -void testSearchTextFrameWrapAround(); -void testDocumentSizeChanged(); -void testSearchAll(); -void testSearchAllNotifications(); -void testPageDownInvalidation(); -void testPartHash(); -void testViewCursors(); -void testShapeViewCursors(); -void testMissingInvalidation(); -void testViewCursorVisibility(); -void testViewCursorCleanup(); -void testViewLock(); -void testTextEditViewInvalidations(); -void testUndoInvalidations(); -void testUndoLimiting(); -void testUndoReordering(); -void testUndoReorderingRedo(); -void testUndoReorderingMulti(); -void testUndoShapeLimiting(); -void testUndoDispatch(); -void testUndoRepairDispatch(); -void testShapeTextUndoShells(); -void testShapeTextUndoGroupShells(); -void testTrackChanges(); -void testTrackChangesCallback(); -void testRedlineUpdateCallback(); -void testSetViewGraphicSelection(); -void testCreateViewGraphicSelection(); -void testCreateViewTextSelection(); -void testRedlineColors(); -void testCommentEndTextEdit(); -void testCommentInsert(); -void testCursorPosition(); -void testPaintCallbacks(); -void testUndoRepairResult(); -void testRedoRepairResult(); -void testDisableUndoRepair(); -void testAllTrackedChanges(); -void testDocumentRepair(); -void testPageHeader(); -void testPageFooter(); -void testTdf115088(); -void testRedlineField(); -void testIMESupport(); -void testIMEFormattingAtEndOfParagraph(); -void testIMEFormattingAfterHeader(); -void testSplitNodeRedlineCallback(); -void testDeleteNodeRedlineCallback(); -void testVisCursorInvalidation(); -void testDeselectCustomShape(); -void testSemiTransparent(); -void testHighlightNumbering(); -void testHighlightNumbering_shd(); -void testPilcrowRedlining(); -void testClipText(); -void testAnchorTypes(); -void testLanguageStatus(); -void testRedlineNotificationDuringSave(); -void testHyperlink(); -void testFieldmark(); -void testDropDownFormFieldButton(); -void testDropDownFormFieldButtonEditing(); -void testDropDownFormFieldButtonNoSelection(); -void testDropDownFormFieldButtonNoItem(); -void testTablePaintInvalidate(); -void testSpellOnlineRenderParameter(); -void testExtTextInputReadOnly(); -void testBulletDeleteInvalidation(); -v
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source
sw/inc/charfmt.hxx|3 ++- sw/inc/fmtcol.hxx |2 +- sw/qa/core/doc/doc.cxx| 30 ++ sw/source/core/doc/fmtcol.cxx | 15 ++- sw/source/core/txtnode/chrfmt.cxx | 19 ++- sw/source/uibase/app/docstyle.cxx |4 ++-- 6 files changed, 67 insertions(+), 6 deletions(-) New commits: commit 424cfae160e21dbc1397c9672adfbc68be715a87 Author: Miklos Vajna AuthorDate: Mon Oct 3 23:04:41 2022 +0200 Commit: Miklos Vajna CommitDate: Fri Oct 7 12:04:35 2022 +0200 tdf#151094 ODT export: fix crash when linked paragraph style is deleted If a document contains a linked paragraph-character style pair and the paragraph style gets deleted, we crash on save. Commit 3227975c0f42ff23d528f5ab94b4538c8af764c (sw: paragraph styles: add doc model & UNO API for a linked character style, 2021-09-24) added support for linked para/char styles, but it failed to get the lifecycle correctly when it comes to deleting these styles. Fix the dangling para/char style references by explicitly looking what styles may refer to us and clear their references. An alternative would be to clear the "link" pointer of our own "link" pointer only, but broken documents may e.g. link multiple paragraph styles to a single character style, so this is probably not enough. (cherry picked from commit 3aff88ae021c571b6e218f6e2a0f62728bb86394) Conflicts: sw/qa/core/doc/doc.cxx Change-Id: I9465d43e90cf54c3c02bffda3e7c75b52c543a65 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141023 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/inc/charfmt.hxx b/sw/inc/charfmt.hxx index e08d2f5f3a3f..84571d26263a 100644 --- a/sw/inc/charfmt.hxx +++ b/sw/inc/charfmt.hxx @@ -36,10 +36,11 @@ class SW_DLLPUBLIC SwCharFormat final : public SwFormat {} public: +~SwCharFormat(); void dumpAsXml(xmlTextWriterPtr pWriter) const; -void SetLinkedParaFormat(SwTextFormatColl& rLink); +void SetLinkedParaFormat(SwTextFormatColl* pLink); const SwTextFormatColl* GetLinkedParaFormat() const; }; diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx index 1b1bd7d2e46d..be547df3d840 100644 --- a/sw/inc/fmtcol.hxx +++ b/sw/inc/fmtcol.hxx @@ -103,7 +103,7 @@ public: inline void SetNextTextFormatColl(SwTextFormatColl& rNext); SwTextFormatColl& GetNextTextFormatColl() const { return *mpNextTextFormatColl; } -void SetLinkedCharFormat(SwCharFormat& rLink); +void SetLinkedCharFormat(SwCharFormat* pLink); const SwCharFormat* GetLinkedCharFormat() const; diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx index 26d02e60318b..ff006bda3faf 100644 --- a/sw/qa/core/doc/doc.cxx +++ b/sw/qa/core/doc/doc.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -255,6 +256,35 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testContentControlDelete) CPPUNIT_ASSERT_EQUAL(OUString("\x0001test\x0001"), pTextNode->GetText()); } +CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testLinkedStyleDelete) +{ +// Given a document with linked styles: myparastyle is linked to mycharstyle and vica versa: +createSwDoc(); +uno::Reference xFactory(mxComponent, uno::UNO_QUERY); +uno::Reference xParaStyle( +xFactory->createInstance("com.sun.star.style.ParagraphStyle"), uno::UNO_QUERY); +uno::Reference xCharStyle( +xFactory->createInstance("com.sun.star.style.CharacterStyle"), uno::UNO_QUERY); +uno::Reference xParaStyles(getStyles("ParagraphStyles"), + uno::UNO_QUERY); +xParaStyles->insertByName("myparastyle", uno::Any(xParaStyle)); +uno::Reference xCharStyles(getStyles("CharacterStyles"), + uno::UNO_QUERY); +xCharStyles->insertByName("mycharstyle", uno::Any(xCharStyle)); +xParaStyle->setPropertyValue("LinkStyle", uno::Any(OUString("mycharstyle"))); +xCharStyle->setPropertyValue("LinkStyle", uno::Any(OUString("myparastyle"))); + +// When deleting the paragraph style (and only that): +xParaStyles->removeByName("myparastyle"); + +// Then make sure we don't crash on save: +uno::Reference xStorable(mxComponent, uno::UNO_QUERY); +uno::Sequence aArgs = { +comphelper::makePropertyValue("FilterName", OUString("writer8")), +}; +xStorable->storeAsURL(maTempFile.GetURL(), aArgs); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx index e35e523b6a92..531a35548818 100644 --- a/sw/source/core/doc/fmtcol.cxx +++ b/sw/source/core/doc/fmtcol.cxx @@ -114,6 +114,19 @@ SwTextFormatColl::~SwTextFormatColl() { if(m_bInSwFntCache) pSwFontCache->Delete( this );
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source xmloff/source
sw/inc/unoprnms.hxx |1 sw/inc/unotextcursor.hxx|1 sw/qa/core/unocore/data/paragraph-marker-formatted-run.docx |binary sw/qa/core/unocore/unocore.cxx | 19 ++ sw/source/core/text/xmldump.cxx |5 sw/source/core/unocore/unoobj.cxx | 81 +++- xmloff/source/text/txtparai.cxx | 17 ++ 7 files changed, 121 insertions(+), 3 deletions(-) New commits: commit 21c8dc9a87a811fef0bc11da3f3448397a396d79 Author: Miklos Vajna AuthorDate: Tue Dec 20 12:14:16 2022 +0100 Commit: Miklos Vajna CommitDate: Tue Jan 3 12:37:25 2023 + sw: fix ODT import of paragraph marker formatting The DOCX bugdoc had a numbering portion which was not bold, even if all characters in the paragrpah was bold. This was rendered fine, but once it was saved to ODT + reloaded, the numbering portion became bold as well, which is buggy. What happens here is that there is one span that covers the entire paragraph (and is bold) and there is an empty span at paragraph end (which is not bold), so the ODT export is fine. But once we import it back, the first span gets "upgraded" to paragraph-level formatting (because SetAttrMode::NOFORMATATTR is not used when inserting the hints) and the second span is not mapped back to the original RES_PARATR_LIST_AUTOFMT in the text node. Fix the problem by 1) improving SwXTextCursor::setPropertyValue() to work with SetAttrMode::NOFORMATATTR when multiple spans are inserted and by 2) extending SwUnoCursorHelper::SetCursorPropertyValue() to create RES_PARATR_LIST_AUTOFMT for empty spans at paragraph end. This way the original doc model and the one created after ODT export + import is much closer to each other. This builds on top of 6249858a8972aef077e0249bd93cfe8f01bce4d6 (sw: ODT import/export of DOCX's paragraph marker formatting, 2022-12-19), previously the ODT export and import of paragraph marker formatting was completely missing. (cherry picked from commit 1feb1aa08421f9d0934ab65ce94cf6054818c0f3) Also includes commit de235fe13a2e5a4db043f44e6d5636e308f2b979 (sw layout xml dump: show numbering portion weight, 2022-12-19). Change-Id: I139e11217dcbc18744aeeb80638090781aa74933 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144676 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144961 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 12f839c2b16a..3c6b5d8464ab 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -502,6 +502,7 @@ #define UNO_NAME_IS_SKIP_HIDDEN_TEXT "IsSkipHiddenText" #define UNO_NAME_IS_SKIP_PROTECTED_TEXT "IsSkipProtectedText" #define UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES "ResetParagraphListAttributes" +#define UNO_NAME_NO_FORMAT_ATTR "NoFormatAttr" #define UNO_NAME_DOCUMENT_INDEX_MARKS "DocumentIndexMarks" #define UNO_NAME_FOOTNOTE_IS_COLLECT_AT_TEXT_END "FootnoteIsCollectAtTextEnd" #define UNO_NAME_FOOTNOTE_IS_RESTART_NUMBERING "FootnoteIsRestartNumbering" diff --git a/sw/inc/unotextcursor.hxx b/sw/inc/unotextcursor.hxx index b055f2d64504..25c71effa57c 100644 --- a/sw/inc/unotextcursor.hxx +++ b/sw/inc/unotextcursor.hxx @@ -76,6 +76,7 @@ private: const CursorTypem_eType; const css::uno::Reference< css::text::XText > m_xParentText; sw::UnoCursorPointer m_pUnoCursor; +SetAttrMode m_nAttrMode = SetAttrMode::DEFAULT; SwUnoCursor& GetCursorOrThrow() { if(!m_pUnoCursor) diff --git a/sw/qa/core/unocore/data/paragraph-marker-formatted-run.docx b/sw/qa/core/unocore/data/paragraph-marker-formatted-run.docx new file mode 100644 index ..c0635c157cc9 Binary files /dev/null and b/sw/qa/core/unocore/data/paragraph-marker-formatted-run.docx differ diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 58723f829439..1566481157e8 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -781,6 +781,25 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testParagraphMarkerODFExport) getXPath(pXmlDoc, "//Special[@nType='PortionType::Number']/SwFont", "color")); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testParagraphMarkerFormattedRun) +{ +// Given a document with a bold run and non-bold paragraph marker: +load(DATA_DIRECTORY, "paragraph-marker-formatted-run.docx"); + +// When saving that as ODT + reload: +reload("writer8", nullptr); + +// Then make sure that the numbering portion is still non-bold, matching Word: +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +// Without the accompanying fix in place, this test would have failed with: +// - Exp
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/qa sw/source writerfilter/source
sw/inc/txatbase.hxx |2 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 43 --- sw/source/filter/ww8/attributeoutputbase.hxx |8 -- sw/source/filter/ww8/docxattributeoutput.cxx | 86 +++--- sw/source/filter/ww8/docxattributeoutput.hxx | 11 -- sw/source/filter/ww8/docxexport.cxx |2 sw/source/filter/ww8/rtfattributeoutput.cxx |3 sw/source/filter/ww8/rtfattributeoutput.hxx |3 sw/source/filter/ww8/wrtw8nds.cxx | 29 +-- sw/source/filter/ww8/ww8atr.cxx |4 - sw/source/filter/ww8/ww8attributeoutput.hxx |2 writerfilter/source/dmapper/DomainMapper.cxx | 15 +-- writerfilter/source/dmapper/DomainMapper_Impl.cxx |8 ++ writerfilter/source/dmapper/SdtHelper.hxx |4 - 14 files changed, 93 insertions(+), 127 deletions(-) New commits: commit faff21eae051e85f46720414dcbba8cc9660 Author: Miklos Vajna AuthorDate: Mon Sep 19 10:01:36 2022 +0200 Commit: Miklos Vajna CommitDate: Tue Sep 20 09:34:41 2022 +0200 sw content controls, plain text: enable DOCX filter with data binding - writerfilter/ had explicit code to not map plain text SDT to Writer content controls if it has data bindings specified, lift this limitation and set the value of content control from data binding, like Word does and Writer did it for input fields since b5c616d10bff3213840d4893d13b4493de71fa56 (tdf#104823: support for sdt plain text fields, 2021-11-24) - call DocxExport::AddSdtData() on the export side to do the opposite on export - give up on the idea to export content controls to DOCX by finding the text attribute in SwWW8AttrIter::OutAttrWithRange(): this needs buffering in both directions (need to start the SDT before the start of the run, need to end it after the end of the run), and solving this using marks and merges at a fast-serializer level looks like hacks on top of hacks. To be more specific, CppunitTest_sw_ooxmlexport7's testSdtAndShapeOverlapping seems to be very hard to fix with this design - instead, give not only the start position but also the length of the run to DocxAttributeOutput::EndRun(), which has random access to the doc model and can look up if there is a content control start or end that needs writing at the current position of the XML output, without any buffering, which also means less code - adapt CppunitTest_sw_ooxmlfieldexport's testSdtBeforeField, which didn't like the empty run at the start of content controls, which seems to be harmless otherwise - fix CppunitTest_sw_ooxmlfieldexport CPPUNIT_TEST_NAME=testSdtDateDuplicate by disabling the "set content control value from data binding" logic for date pickers because that logic in writerfilter/ sets the value as-is and it has to consider the requested date format before this can be enabled As a side effect, this gives PDF export for plain text SDTs, even if they have data binding set. CppunitTest_sw_ooxmlfieldexport's testTdf104823 is now updated to ensure that we import such SDTs as Writer content controls. (cherry picked from commit de90c192cb8f1f03a4028493d8bfe9a127a76b2a) Conflicts: sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/wrtw8nds.cxx writerfilter/source/dmapper/SdtHelper.hxx Change-Id: I749a845b5a25454c51066b8ded892682f523b6b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140180 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 183e254f8817..00e2f9b51470 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -132,7 +132,7 @@ public: virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; -class SAL_DLLPUBLIC_RTTI SwTextAttrEnd : public virtual SwTextAttr +class SW_DLLPUBLIC SwTextAttrEnd : public virtual SwTextAttr { protected: sal_Int32 m_nEnd; diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 98a5b6ab6a15..9cf424f8aa07 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -549,7 +549,8 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testSdtBeforeField, "sdt-before-field.docx") { xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); // Make sure the field doesn't sneak inside the SDT: the SDT should contain only a single run (there were 6 ones). -assertXPath(pXmlDoc, "//w:sdt/w:sdtContent/w:r", 1); +assertXPath(pXmlDoc, "//w:p/w:sdt/w:sdtContent/w:r/w:t", 1); +assertXPath(pXmlDoc, "//w:p/w:r/w:fldChar", 3); } DECLARE_OOXMLEXPORT_