summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf105625.fodt8
-rw-r--r--sw/qa/extras/uiwriter/data/tdf90362.fodt6
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx26
-rw-r--r--sw/source/core/crsr/pam.cxx52
4 files changed, 54 insertions, 38 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf105625.fodt b/sw/qa/extras/uiwriter/data/tdf105625.fodt
new file mode 100644
index 000000000000..44c0577d301b
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf105625.fodt
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <text:p><field:fieldmark field:type="vnd.oasis.opendocument.field.FORMCHECKBOX"/></text:p>
+ </office:text>
+ </office:body>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/data/tdf90362.fodt b/sw/qa/extras/uiwriter/data/tdf90362.fodt
index bf74255aee7f..97db3d59a71a 100644
--- a/sw/qa/extras/uiwriter/data/tdf90362.fodt
+++ b/sw/qa/extras/uiwriter/data/tdf90362.fodt
@@ -3,8 +3,10 @@
<office:body>
<office:text>
<text:p>Before</text:p>
- <text:p><field:fieldmark-start text:name="__Fieldmark__2_34585131" field:type="xxx"/><field:fieldmark-end/></text:p>
+ <text:section text:name="Protected" text:protected="true">
+ <text:p>Inside</text:p>
+ </text:section>
<text:p>After</text:p>
</office:text>
</office:body>
-</office:document>
+</office:document> \ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 0ddc4397b8a7..da819d402a23 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -226,6 +226,7 @@ public:
void testTdf35021_tabOverMarginDemo();
void testTdf104492();
void testTdf105417();
+ void testTdf105625();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -346,6 +347,7 @@ public:
CPPUNIT_TEST(testTdf35021_tabOverMarginDemo);
CPPUNIT_TEST(testTdf104492);
CPPUNIT_TEST(testTdf105417);
+ CPPUNIT_TEST(testTdf105625);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3030,17 +3032,21 @@ void SwUiWriterTest::testTdf88899()
void SwUiWriterTest::testTdf90362()
{
- // First check if the end of the second paragraph is indeed protected.
SwDoc* pDoc = createDoc("tdf90362.fodt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ // Ensure correct initial setting
+ comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, "org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+ // First check if the end of the second paragraph is indeed protected.
pWrtShell->EndPara();
pWrtShell->Down(/*bSelect=*/false);
CPPUNIT_ASSERT_EQUAL(true, pWrtShell->HasReadonlySel());
// Then enable ignoring of protected areas and make sure that this time the cursor is read-write.
- uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, "org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", css::uno::Any(true), comphelper::EConfigurationModes::Standard);
CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
+ // Clean up, otherwise following tests will have that option set
+ comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, "org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", css::uno::Any(false), comphelper::EConfigurationModes::Standard);
}
void SwUiWriterTest::testUndoCharAttribute()
@@ -4265,6 +4271,22 @@ void SwUiWriterTest::testTdf105417()
aWrap.SpellDocument();
}
+void SwUiWriterTest::testTdf105625()
+{
+ // We should be able to edit at positions adjacent to fields.
+ // Check if the start and the end of the only paragraph are not protected
+ // (they are adjacent to FORMCHECKBOX)
+ SwDoc* pDoc = createDoc("tdf105625.fodt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
+ // Ensure correct initial setting
+ comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, "org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+ pWrtShell->SttPara();
+ CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
+ pWrtShell->EndPara();
+ CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index d5cf3da666e4..ee5ad68010ed 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -564,7 +564,7 @@ static const SwFrame* lcl_FindEditInReadonlyFrame( const SwFrame& rFrame )
}
/// is in protected section or selection surrounds something protected
-bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const
+bool SwPaM::HasReadonlySel( bool bFormView, bool /*bAnnotationMode*/ ) const
{
bool bRet = false;
@@ -675,32 +675,33 @@ bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const
}
}
- //FIXME FieldBk
- // TODO: Form Protection when Enhanced Fields are enabled
const SwDoc *pDoc = GetDoc();
const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
- sw::mark::IMark* pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : nullptr;
- sw::mark::IMark* pB = GetMark( ) ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
-
- bool bUnhandledMark = false;
- sw::mark::IFieldmark* pFieldmark = pMarksAccess->getFieldmarkFor( *GetPoint() );
- if ( pFieldmark )
- bUnhandledMark = pFieldmark->GetFieldname( ) == ODF_UNHANDLED;
+ sw::mark::IFieldmark* pA = GetPoint() ? pMarksAccess->getFieldmarkFor( *GetPoint( ) ) : nullptr;
+ sw::mark::IFieldmark* pB = GetMark() ? pMarksAccess->getFieldmarkFor( *GetMark( ) ) : pA;
if (!bRet)
{
+ bool bUnhandledMark = pA && pA->GetFieldname( ) == ODF_UNHANDLED;
// Unhandled fieldmarks case shouldn't be edited manually to avoid breaking anything
if ( ( pA == pB ) && bUnhandledMark )
bRet = true;
else
{
- // Form protection case
- bool bAtStartA = pA != nullptr && pA->GetMarkStart() == *GetPoint();
- bool bAtStartB = pB != nullptr && pB->GetMarkStart() == *GetMark();
- bRet = ( pA != pB ) || bAtStartA || bAtStartB;
- bool bProtectForm = pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM );
- if ( bProtectForm )
- bRet |= ( pA == nullptr || pB == nullptr );
+ bool bAtStartA = (pA != nullptr) && (pA->GetMarkStart() == *GetPoint());
+ bool bAtStartB = (pB != nullptr) && (pB->GetMarkStart() == *GetMark());
+
+ if (pA != pB)
+ {
+ // If both points are either outside or at marks edges (i.e. selection either
+ // touches fields, or fully encloses it), then don't disable editing
+ bRet = !( ( !pA || bAtStartA ) && ( !pB || bAtStartB ) );
+ }
+ if( !bRet && pDoc->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM ) )
+ {
+ // Form protection case
+ bRet = ( pA == nullptr ) || ( pB == nullptr ) || ( bAtStartA ) || ( bAtStartB );
+ }
}
}
else
@@ -708,23 +709,6 @@ bool SwPaM::HasReadonlySel( bool bFormView, bool bAnnotationMode ) const
bRet = !( pA == pB && pA != nullptr );
}
- // Don't allow inserting characters between the 'field mark end' and
- // the 'comment anchor', unless the cursor is inside the annotation.
- if (!bRet && !bAnnotationMode)
- {
- if (!pA && GetPoint() && GetPoint()->nNode.GetNode().IsTextNode() && GetPoint()->nContent.GetIndex() > 0)
- {
- // getFieldmarkFor() searches for >= start and < end, so check for
- // the previous character, to also get the fieldmark, if we're
- // exactly at the end.
- SwPosition aPrevChar(*GetPoint());
- --aPrevChar.nContent;
- pFieldmark = pMarksAccess->getFieldmarkFor(aPrevChar);
- if (pFieldmark && pFieldmark->GetMarkEnd() == *GetPoint())
- bRet = true;
- }
- }
-
return bRet;
}