summaryrefslogtreecommitdiff
path: root/xmloff/source/text/xmlcontentcontrolcontext.cxx
AgeCommit message (Collapse)Author
2022-12-21sw content controls: enhance preserve idJustin Luth
Squashed commit including NFC cleanup docxattributeoutput: use existing function to clear fd14dd0e4c6a7ea0866a686f653db90301d664b6 Follow-up to 100c914d44ae8f362924fe567d7d41d0033ae8ad which added the initial id preservation for DOCX. adding DOCX block SDT grabbaging, ODF import/export [content controls can't exist in DOC format] The ID field is CRITICAL to preserve for VBA purposes. This patch adjusts BlockSDT to also round-trip the id instead of just creating a random one. m_nRunSdtPrToken <never equals> FSNS(XML_w, XML_id) since 2021 with 5f3af56b2c0ef6c628a7cfe5ce6e86f8e1765f5f, so I removed that part of the clause. I had thought about changing the ID to use a string instead of an int, but then the integer version was adopted to fix a regression in the commit mentioned earlier. I think it is AWFUL to have a number as the identifier when it will be used in StarBASIC. The VBA guys have to deal with it, but it would be nice to do something reasonable for LO native access to content controls. However, the concern would be if we allow VBA macro content created in LO to be exported to DOCX format - that would cause problems converting from a string ID to a number ID. VBA editing already is happening to some extent, and mmeeks seems interested in enabling it. So over-all it seems best to just stick with an integer ID. I used the commits for <w:alias> and <w:tag> to compose this patch. XML_ID already existed in include/xmloff/xmltoken.hxx and "id" already exists in xmloff/source/token/tokens.txt The ID can be used in VBA to select a specific control. The id (which is a positive or negative integer in DOCX) specifies a unique control - either by passing the number as a string (of the UNSIGNED value) or by passing as a float (specified with #). For example: msgbox ActiveDocument.ContentControls(2587720202#).ID msgbox ActiveDocument.ContentControls("2587720202").ID but not as an integer since that is used for index access. dim index as integer index = 1 msgbox ActiveDocument.ContentControls(index).ID make CppunitTest_writerfilter_dmapper CPPUNIT_TEST_NAME=testSdtRunRichText make CppunitTest_sw_ooxmlexport17 CPPUNIT_TEST_NAME=testDateContentControlExport make CppunitTest_sw_core_unocore CPPUNIT_TEST_NAME=testContentControlDate make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlExport make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlImport Change-Id: I5c4022dc932d941fad9da6d75ce899ee1ff66ff5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142818 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144625 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2022-12-21tdf#151548 sw content controls: preserve tabIndexJustin Luth
This has to be vital to keyboard navigation. Certainly it is good to have it imported before we start to consider tab-movements for form controls. All tabIndex 1's are processed (in placement order) and then the 2's etc. 0's are to be done last. XML_TAB_INDEX already existed in include/xmloff/xmltoken.hxx and "tab-index" already exists in xmloff/source/token/tokens.txt make CppunitTest_writerfilter_dmapper CPPUNIT_TEST_NAME=testSdtRunRichText make CppunitTest_sw_ooxmlexport17 CPPUNIT_TEST_NAME=testDateContentControlExport make CppunitTest_sw_core_unocore CPPUNIT_TEST_NAME=testContentControlDate make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlExport make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlImport No existing unit test found containing blockSDT with tabIndex. Change-Id: I8a958844e6192b079a2b22a62dedfd8739021f4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143603 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144623 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2022-12-20tdf#151548 sw content controls: preserve lockJustin Luth
DOCX SdtControls can be locked in two ways: -Content Control cannot be deleted (sdtLocked) -Contents cannot be edited (contentLocked) or both (sdtContentLocked) make CppunitTest_writerfilter_dmapper CPPUNIT_TEST_NAME=testSdtRunRichText make CppunitTest_sw_ooxmlexport4 CPPUNIT_TEST_NAME=testSimpleSdts make CppunitTest_sw_ooxmlexport17 CPPUNIT_TEST_NAME=testDateContentControlExport make CppunitTest_sw_core_unocore CPPUNIT_TEST_NAME=testContentControlDate make CppunitTest_sw_macros_test CPPUNIT_TEST_NAME=testVba make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlExport make CppunitTest_xmloff_text CPPUNIT_TEST_NAME=testAliasContentControlImport Change-Id: I5a82d9f6b5103a4902f59af66cd8a99addd4e690 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143542 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144553 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
2022-11-10sw content controls: allow no list items in a dropdownMiklos Vajna
- Replace SwContentControl::HasListItems(), which assumed that the type is dropdown if we have list items. This is not valid, it's OK to have a dropdown with no list items. Add a GetDropDown() instead to check for the type, explicitly. - UNO API sets the dropdown bit when list items are set and the type is not expilcitly combo box or drop down, to keep backwards compatibility with existing documents. - No change to the edit shell, SwDropDownContentControlButton already checked if items are empty and used STR_DROP_DOWN_EMPTY_LIST in that case, but that was dead code previously. - ODT & DOCX filters are now updated, ODF has a new <loext:content-control loext:dropdown="..."> attribute to specify that the type is a dropdown, explicitly. (cherry picked from commit 56db6406b0b63a2d2d99024e7c311ebd874f3893) Conflicts: xmloff/qa/unit/text.cxx Change-Id: Id577ba9639151549a8f953aab31685a73a898504 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142544 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-10-18sw content controls, alias and tag: add ODT filterMiklos Vajna
Map the Alias/Tag UNO properties to: <loext:content-control loext:alias="..." loext:tag="..."> on export, and do the opposite on import. (cherry picked from commit 888a8c3ca70ed19309c15ff7b9f0968ece337cb5) Conflicts: xmloff/source/token/tokens.txt Change-Id: Icecbe9037ede0bf8d72d52f2db44328a8db1d83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141500 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
2022-09-23sw content controls, combo box: add ODT filterMiklos Vajna
Map the ComboBox UNO property to: <loext:content-control loext:combbobox="..."> on export, and do the opposite on import. (cherry picked from commit 21d93d8d2ffd9c5d5cfe9064590b35e0727295c9) Change-Id: I33c162ace15025c8031eb678ba5a43ac085c4b6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140430 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-07-27sw content controls, date: add ODT filterMiklos Vajna
Map the PlainText UNO property to: <loext:content-control loext:plain-text="..."> on export, and do the opposite on import. (cherry picked from commit 33cf26c8b6dc6cf38edf2d22cfefbd00904d9da8) Conflicts: xmloff/source/token/tokens.txt Change-Id: Icec0c35b2b9fca53104e6526c98083db52df5d42 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137472 Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-31sw content controls, date: add current date handlingMiklos Vajna
While working on the DOCX import for dates, it turns out there is a need to store the selected date in machine-readable format as well. This is useful, because once the timestamp is formatted, the user is allowed to hand-edit the result, so otherwise the selected date would be lost. This commit adds: - doc model & UNO API - click handler (store the selected date, default to the current date in the date picker if possible) - ODT filter - DOCX export And tests for all these. (cherry picked from commit 79baafccf3d390810f516b2cf9cb3ad2b4e9e63b) Change-Id: I00f4e87ebfe0e8a19486367c32d472ccd2ff16a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135150 Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-30sw content controls, date: add ODT filterMiklos Vajna
Map the Date, DateFormat and DateLanguage UNO properties to: <loext:content-control loext:date="..." loext:date-format="..." loext:date-rfc-language-tag="..."> And do the opposite on import. (cherry picked from commit b3c6511659c58bcc75a9742e0ae0cc436b6f6825) Change-Id: I16d3f755d77ed20380d877ba65dfe6d063f2bec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135117 Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-20sw content controls, picture: add ODT filterMiklos Vajna
Map Picture UNO property on content controls to: <loext:content-control loext:picture="..."> And do the opposite on import. (cherry picked from commit 81ce15c466cda946ae94f38904215f24555021ad) Change-Id: I47c3d04c505ba94da958d5d6b6b2c883236afc3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134665 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-11sw content controls, drop-down: add ODT filterMiklos Vajna
Map each list item to a dedicated XML element: <loext:list-item loext:display-text="..." loext:value="..."> And do the opposite on import. (cherry picked from commit c3f4c43694f0f9aec35193ccf40f0e7c8476fdc3) Change-Id: I59a536a8317a3bb24919107b4449f858d5f6de96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134145 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-05-02sw content controls, checkbox: add ODT filterMiklos Vajna
Map the 4 new UNO properties to XML attributes: - Checkbox <-> loext:checkbox="..." - Checked <-> loext:checked="..." - CheckedState <-> loext:checked-state="..." - UncheckedState <-> loext:unchecked-state="..." (cherry picked from commit c2fab664a887b16cb78570851ceffcacd26815f7) Change-Id: Ia4623004ee39c77f5f242c2d720bc188e4dd9433 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133643 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-04-22sw content controls: add ODT importMiklos Vajna
Map <loext:content-control loext:showing-place-holder="..."> to com.sun.star.text.ContentControl and set its ShowingPlaceHolder property based on the XML attribute. This requires moving XMLImpSpanContext_Impl to txtparai.hxx, otherwise XMLContentControlContext would have to be in txtparai.cxx, which is already large. (cherry picked from commit d1649e5d38b51cd422302e566719a2c5aff42b2f) Change-Id: I9a915868160ebcc0e98ded61bfab72f32864bd76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133316 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>