[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/Library_sw.mk sw/qa sw/source sw/uiconfig sw/UIConfig_swriter.mk
sw/Library_sw.mk |1 sw/UIConfig_swriter.mk |1 sw/inc/formatcontentcontrol.hxx | 10 +++ sw/qa/core/unocore/unocore.cxx |7 -- sw/qa/uibase/wrtsh/wrtsh.cxx | 37 ++ sw/source/core/crsr/crstrvl.cxx |2 sw/source/core/crsr/datecontentcontrolbutton.cxx | 59 +++ sw/source/core/crsr/viscrs.cxx | 21 sw/source/core/inc/datecontentcontrolbutton.hxx | 41 +++ sw/source/core/txtnode/attrcontentcontrol.cxx| 35 + sw/source/uibase/wrtsh/wrtsh3.cxx| 21 sw/uiconfig/swriter/ui/contentcontrolcalendar.ui | 28 ++ 12 files changed, 256 insertions(+), 7 deletions(-) New commits: commit 87061501b4030736fd448c0df2f1e8fd007594fa Author: Miklos Vajna AuthorDate: Wed May 25 09:58:28 2022 +0200 Commit: Miklos Vajna CommitDate: Mon May 30 14:25:49 2022 +0200 sw content controls, date: show a date picker on click - add a new SwContentControl::GetDateString() that knows how to produce a formatted date, taking the language and the date format into account - add a new SwDateContentControlButton that knows how to open popup a calendar on click and that puts the selected date into SwContentControl::m_oSelectedDate - extend SwWrtShell::GotoContentControl() to consume that selected date & update the document text accordingly - in case SwSelPaintRects::HighlightContentControl() notices a date content control, create an instance of this newly introduced SwDateContentControlButton (cherry picked from commit ce5d609da9d20b3c91f6f8eb4ee88451cbd55a9d) Change-Id: Ia2cb0fa3aefbf543b8dc2e96bcebb41408eb12c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135116 Tested-by: Miklos Vajna Reviewed-by: Miklos Vajna diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 4f80a864376a..a49d53d0509f 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -157,6 +157,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/crsr/crstrvl1 \ sw/source/core/crsr/DateFormFieldButton \ sw/source/core/crsr/DropDownFormFieldButton \ +sw/source/core/crsr/datecontentcontrolbutton \ sw/source/core/crsr/dropdowncontentcontrolbutton \ sw/source/core/crsr/findattr \ sw/source/core/crsr/findcoll \ diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk index 0a558ebd7381..73abd66dee9b 100644 --- a/sw/UIConfig_swriter.mk +++ b/sw/UIConfig_swriter.mk @@ -121,6 +121,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\ sw/uiconfig/swriter/ui/combobox \ sw/uiconfig/swriter/ui/comboboxfragment \ sw/uiconfig/swriter/ui/conditionpage \ + sw/uiconfig/swriter/ui/contentcontrolcalendar \ sw/uiconfig/swriter/ui/contentcontroldlg \ sw/uiconfig/swriter/ui/contentcontroldropdown \ sw/uiconfig/swriter/ui/contentcontrollistitemdlg \ diff --git a/sw/inc/formatcontentcontrol.hxx b/sw/inc/formatcontentcontrol.hxx index b4737c71ae90..00e52fc3d649 100644 --- a/sw/inc/formatcontentcontrol.hxx +++ b/sw/inc/formatcontentcontrol.hxx @@ -136,6 +136,9 @@ class SW_DLLPUBLIC SwContentControl : public sw::BroadcastingModify /// Stores a list item index, in case the doc model is not yet updated. std::optional m_oSelectedListItem; +/// Stores a date timestamp, in case the doc model is not yet updated. +std::optional m_oSelectedDate; + public: SwTextContentControl* GetTextAttr() const; @@ -211,6 +214,9 @@ public: OUString GetDateLanguage() const { return m_aDateLanguage; } +/// Formats m_oSelectedDate, taking m_aDateFormat and m_aDateLanguage into account. +OUString GetDateString() const; + void SetSelectedListItem(std::optional oSelectedListItem) { m_oSelectedListItem = oSelectedListItem; @@ -218,6 +224,10 @@ public: std::optional GetSelectedListItem() const { return m_oSelectedListItem; } +void SetSelectedDate(std::optional oSelectedDate) { m_oSelectedDate = oSelectedDate; } + +std::optional GetSelectedDate() const { return m_oSelectedDate; } + virtual void dumpAsXml(xmlTextWriterPtr pWriter) const; }; diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 998c4d285adc..edc11b03b9fb 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -538,12 +538,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) 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); -
[Libreoffice-commits] core.git: Branch 'distro/collabora/co-22.05' - sw/inc sw/Library_sw.mk sw/qa sw/source
sw/Library_sw.mk |1 sw/inc/unocoll.hxx |1 sw/qa/core/unocore/unocore.cxx | 32 sw/source/core/bastyp/init.cxx |2 sw/source/core/inc/unolinebreak.hxx | 91 +++ sw/source/core/txtnode/attrlinebreak.cxx |1 sw/source/core/txtnode/thints.cxx|5 sw/source/core/unocore/unocoll.cxx |7 sw/source/core/unocore/unolinebreak.cxx | 236 +++ 9 files changed, 374 insertions(+), 2 deletions(-) New commits: commit 461de6f712ebdc5a5a3f0e0563c50d92614f0760 Author: Miklos Vajna AuthorDate: Tue Mar 1 16:44:03 2022 +0100 Commit: Miklos Vajna CommitDate: Fri Mar 25 13:41:59 2022 +0100 sw clearing breaks: add UNO API to insert this This only allows the clear=all break type, the others are not yet handled. (cherry picked from commit 5028e5670da25ec1e862789b744c32e6108b) Conflicts: sw/qa/core/unocore/unocore.cxx Change-Id: Id4981b3cc0a8faca2166ad93827ae547f5539095 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132106 Tested-by: Jenkins CollaboraOffice Reviewed-by: Miklos Vajna diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 0f594e203f59..ef3a27b74458 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -482,6 +482,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/unocore/unoframe \ sw/source/core/unocore/unoftn \ sw/source/core/unocore/unoidx \ +sw/source/core/unocore/unolinebreak \ sw/source/core/unocore/unomap \ sw/source/core/unocore/unomap1 \ sw/source/core/unocore/unoobj \ diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index ae16ab4ab7bc..821d50ab4a2c 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -176,6 +176,7 @@ enum class SwServiceType { VbaGlobals = 113, StyleTable = 114, StyleCell = 115, +LineBreak = 116, Invalid = USHRT_MAX }; diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index a480a082f975..ddf8d4bb5362 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include using namespace ::com::sun::star; @@ -215,6 +217,36 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testBrokenEmbeddedObject) xEmbeddedObject->supportsService("com.sun.star.comp.embed.OCommonEmbeddedObject")); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakInsert) +{ +// Given an empty document: +SwDoc* pDoc = createSwDoc(); + +// When inserting a line-break with properties: +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 xText = xTextDocument->getText(); +uno::Reference xCursor = xText->createTextCursor(); +xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false); + +// Then make sure that both the line break and its matching text attribute is inserted: +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +SwNodeOffset nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); +SwTextNode* pTextNode = pDoc->GetNodes()[nIndex]->GetTextNode(); +// Without the accompanying fix in place, this test would have failed with: +// - Expected: "\n" (newline) +// - Actual : "" (empty string) +// i.e. SwXLineBreak::attach() did not insert the newline + its text attribute. +CPPUNIT_ASSERT_EQUAL(OUString("\n"), pTextNode->GetText()); +SwTextAttr* pAttr = pTextNode->GetTextAttrForCharAt(0, RES_TXTATR_LINEBREAK); +CPPUNIT_ASSERT(pAttr); +auto pTextLineBreak = static_cast(pAttr); +auto& rFormatLineBreak = static_cast(pTextLineBreak->GetAttr()); +CPPUNIT_ASSERT_EQUAL(SwLineBreakClear::ALL, rFormatLineBreak.GetValue()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index b6703dcd1d0d..87cb7dfa3127 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -319,7 +319,7 @@ SfxItemInfo aSlotTab[] = { 0, false }, // RES_TXTATR_FLYCNT { 0, false }, // RES_TXTATR_FTN { 0, false }, // RES_TXTATR_ANNOTATION -{ 0, true }, // RES_TXTATR_LINEBREAK +{ 0, false }, // RES_TXTATR_LINEBREAK { 0, true }, // RES_TXTATR_DUMMY1 { 0, true }, // RES_TXTATR_DUMMY2 diff --git a/sw/source/core/inc/unolinebreak.hxx