Created attachment 147672 [details] Original ODT document with text and one additional protected section How to reproduce: * resave of the attached ODT document (with one protected sections inside) into DOCX * all content became protected including protected section.
Patch development is here: https://gerrit.libreoffice.org/#/c/65278/
Question: In unit test scenario, I would like to try to edit text inside protected section and outside it, to prove that LO prevents editing if area is protected. Unfortunately my code always allows to modify the text inside the DOM: Code-1: uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> xText(textDocument->getText(), uno::UNO_QUERY); uno::Reference<text::XTextRange> xParagraphInProtectedSection = getParagraphOfText( 1, xText ); xParagraphInProtectedSection->setString(OUString( "New text" )); CPPUNIT_ASSERT_EQUAL( OUString( "Old text" ), xText->getString()); Code-2: // try to insert some text into protected area { SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent()); SwNodeIndex aDocStart(*aDocEnd.GetNode().StartOfSectionNode(), 3); SwPaM aPaM(aDocStart); pDoc->getIDocumentContentOperations().InsertString(aPaM, "New text"); } // check if content was not changed { SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent()); SwNodeIndex aDocStart(*aDocEnd.GetNode().StartOfSectionNode(), 3); SwNode& rNode = aDocStart.GetNode(); SwTextNode* pTextNode = rNode.GetTextNode(); CPPUNIT_ASSERT(pTextNode); CPPUNIT_ASSERT_EQUAL(OUString("Old text"), pTextNode->GetText()); } Any ideas? Is it really possible to use protected areas in UNO interface to prevent modification of the content?
Serge Krot committed a patch related to this issue. It has been pushed to "libreoffice-6-2": https://git.libreoffice.org/core/+/63ec2e8d07dff652a68c9dc96859c4c61f26b9df%5E%21 tdf#122201 sw: DOCX: allow editing of unprotected areas in protected doc It will be available in 6.2.0.2. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Serge Krot committed a patch related to this issue. It has been pushed to "libreoffice-6-1": https://git.libreoffice.org/core/+/46c6c414a6df79575517f5df67510d6f4e3d0128%5E%21 tdf#122201 sw: DOCX: allow editing of unprotected areas in protected doc It will be available in 6.1.6. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
Thorsten Behrens committed a patch related to this issue. It has been pushed to "libreoffice-6-1": https://git.libreoffice.org/core/+/a7fd527ece87a1c25fe0d8a9811fe2b230eeea88%5E%21 Revert "tdf#122201 sw: DOCX: allow editing of unprotected areas in protected doc" It will be available in 6.1.6. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.