Kaydet (Commit) 4a59cadd authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#90362 sw: config option for ignoring protected areas

Change-Id: Idfa62aa5bbccf62ee85f863150e13f80b8b5db90
Reviewed-on: https://gerrit.libreoffice.org/15181Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 37674e1f
...@@ -2359,6 +2359,13 @@ ...@@ -2359,6 +2359,13 @@
</info> </info>
<value>true</value> <value>true</value>
</prop> </prop>
<prop oor:name="IgnoreProtectedArea" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies whether modifications are accepted in a protected area.</desc>
<label>Ignore protected areas</label>
</info>
<value>false</value>
</prop>
</group> </group>
</group> </group>
<group oor:name="Revision"> <group oor:name="Revision">
......
...@@ -795,6 +795,7 @@ ...@@ -795,6 +795,7 @@
#define FN_SHAPE_ENDPOSITION_IN_HORI_L2R (FN_PARAM2+26) #define FN_SHAPE_ENDPOSITION_IN_HORI_L2R (FN_PARAM2+26)
#define FN_PARAM_PAM (FN_PARAM2+27) /* Point and Mark */ #define FN_PARAM_PAM (FN_PARAM2+27) /* Point and Mark */
#define FN_TEXT_BOX (FN_PARAM2+28) /* TextBox Property*/ #define FN_TEXT_BOX (FN_PARAM2+28) /* TextBox Property*/
#define FN_PARAM_IGNORE_PROTECTED (FN_PARAM2+29) /* Ignore protected areas */
// Status: not more than 19! // Status: not more than 19!
#define FN_STAT_PAGE (FN_STAT + 1) #define FN_STAT_PAGE (FN_STAT + 1)
......
...@@ -69,6 +69,7 @@ namespace svtools{ class ColorConfig;} ...@@ -69,6 +69,7 @@ namespace svtools{ class ColorConfig;}
#define VIEWOPT_CORE2_CRSR_IN_PROT 0x00000008L #define VIEWOPT_CORE2_CRSR_IN_PROT 0x00000008L
#define VIEWOPT_CORE2_PDF_EXPORT 0x00000010L #define VIEWOPT_CORE2_PDF_EXPORT 0x00000010L
#define VIEWOPT_CORE2_PRINTING 0x00000020L #define VIEWOPT_CORE2_PRINTING 0x00000020L
#define VIEWOPT_CORE2_IGNORE_PROT 0x00000040L
#define VIEWOPT_2_H_RULER 0x00000400L #define VIEWOPT_2_H_RULER 0x00000400L
#define VIEWOPT_2_VSCROLLBAR 0x00000800L #define VIEWOPT_2_VSCROLLBAR 0x00000800L
...@@ -103,7 +104,7 @@ namespace svtools{ class ColorConfig;} ...@@ -103,7 +104,7 @@ namespace svtools{ class ColorConfig;}
// Implementation in core/text/txtpaint.cxx. // Implementation in core/text/txtpaint.cxx.
extern void SyncVout( const OutputDevice *pOut ); extern void SyncVout( const OutputDevice *pOut );
class SwViewOption class SW_DLLPUBLIC SwViewOption
{ {
static Color aDocColor; // color of document boundaries static Color aDocColor; // color of document boundaries
static Color aDocBoundColor; // color of document boundaries static Color aDocBoundColor; // color of document boundaries
...@@ -342,6 +343,16 @@ public: ...@@ -342,6 +343,16 @@ public:
inline void SetCursorInProtectedArea(bool b) inline void SetCursorInProtectedArea(bool b)
{ b ? (nCore2Options |= VIEWOPT_CORE2_CRSR_IN_PROT) : (nCore2Options &= ~VIEWOPT_CORE2_CRSR_IN_PROT);} { b ? (nCore2Options |= VIEWOPT_CORE2_CRSR_IN_PROT) : (nCore2Options &= ~VIEWOPT_CORE2_CRSR_IN_PROT);}
bool IsIgnoreProtectedArea() const
{
return (nCore2Options & VIEWOPT_CORE2_IGNORE_PROT) != 0;
}
void SetIgnoreProtectedArea(bool bSet)
{
bSet ? (nCore2Options |= VIEWOPT_CORE2_IGNORE_PROT) : (nCore2Options &= ~VIEWOPT_CORE2_IGNORE_PROT);
}
inline bool IsPDFExport() const inline bool IsPDFExport() const
{return (nCore2Options & VIEWOPT_CORE2_PDF_EXPORT) != 0; } {return (nCore2Options & VIEWOPT_CORE2_PDF_EXPORT) != 0; }
...@@ -553,7 +564,7 @@ public: ...@@ -553,7 +564,7 @@ public:
static Color& GetSpellColor(); static Color& GetSpellColor();
static Color& GetSmarttagColor(); static Color& GetSmarttagColor();
static Color& GetShadowColor(); static Color& GetShadowColor();
SW_DLLPUBLIC static Color& GetFontColor(); static Color& GetFontColor();
static Color& GetFieldShadingsColor(); static Color& GetFieldShadingsColor();
static Color& GetSectionBoundColor(); static Color& GetSectionBoundColor();
static Color& GetPageBreakColor(); static Color& GetPageBreakColor();
......
<?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>Before</text:p>
<text:p><field:fieldmark-start text:name="__Fieldmark__2_34585131" field:type="xxx"/><field:fieldmark-end/></text:p>
<text:p>After</text:p>
</office:text>
</office:body>
</office:document>
...@@ -88,6 +88,7 @@ public: ...@@ -88,6 +88,7 @@ public:
void testCp1000115(); void testCp1000115();
void testTdf90003(); void testTdf90003();
void testSearchWithTransliterate(); void testSearchWithTransliterate();
void testTdf90362();
CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward); CPPUNIT_TEST(testReplaceForward);
...@@ -121,6 +122,7 @@ public: ...@@ -121,6 +122,7 @@ public:
CPPUNIT_TEST(testCp1000115); CPPUNIT_TEST(testCp1000115);
CPPUNIT_TEST(testTdf90003); CPPUNIT_TEST(testTdf90003);
CPPUNIT_TEST(testSearchWithTransliterate); CPPUNIT_TEST(testSearchWithTransliterate);
CPPUNIT_TEST(testTdf90362);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -890,6 +892,24 @@ void SwUiWriterTest::testSearchWithTransliterate() ...@@ -890,6 +892,24 @@ void SwUiWriterTest::testSearchWithTransliterate()
CPPUNIT_ASSERT_EQUAL(1,(int)case2); CPPUNIT_ASSERT_EQUAL(1,(int)case2);
} }
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();
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.
pWrtShell->Up(/*bSelect=*/false);
SwViewOption aViewOptions(*pWrtShell->GetViewOptions());
aViewOptions.SetIgnoreProtectedArea(true);
pWrtShell->ApplyViewOptions(aViewOptions);
pWrtShell->Down(/*bSelect=*/false);
CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -3022,7 +3022,8 @@ void SwCrsrShell::SetReadOnlyAvailable( bool bFlag ) ...@@ -3022,7 +3022,8 @@ void SwCrsrShell::SetReadOnlyAvailable( bool bFlag )
bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const
{ {
bool bRet = false; bool bRet = false;
if ( IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ) // If protected area is to be ignored, then selections are never read-only.
if ((IsReadOnlyAvailable() || GetViewOptions()->IsFormView()) && !GetViewOptions()->IsIgnoreProtectedArea())
{ {
if ( m_pTblCrsr != NULL ) if ( m_pTblCrsr != NULL )
{ {
......
...@@ -1278,6 +1278,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent, ...@@ -1278,6 +1278,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent,
get(m_pCursorProtFrame, "crsrprotframe"); get(m_pCursorProtFrame, "crsrprotframe");
get(m_pCrsrInProtCB, "cursorinprot"); get(m_pCrsrInProtCB, "cursorinprot");
get(m_pIgnoreProtCB, "ignoreprot");
get(m_pMathBaselineAlignmentCB, "mathbaseline"); get(m_pMathBaselineAlignmentCB, "mathbaseline");
...@@ -1311,6 +1312,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent, ...@@ -1311,6 +1312,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent,
m_pCursorProtFrame->Hide(); m_pCursorProtFrame->Hide();
m_pCrsrInProtCB->Hide(); m_pCrsrInProtCB->Hide();
m_pIgnoreProtCB->Hide();
} }
} }
...@@ -1367,6 +1369,12 @@ bool SwShdwCrsrOptionsTabPage::FillItemSet( SfxItemSet* rSet ) ...@@ -1367,6 +1369,12 @@ bool SwShdwCrsrOptionsTabPage::FillItemSet( SfxItemSet* rSet )
bRet = true; bRet = true;
} }
if (m_pIgnoreProtCB->IsValueChangedFromSaved())
{
rSet->Put(SfxBoolItem(FN_PARAM_IGNORE_PROTECTED, m_pIgnoreProtCB->IsChecked()));
bRet = true;
}
const SwDocDisplayItem* pOldAttr = static_cast<const SwDocDisplayItem*>( const SwDocDisplayItem* pOldAttr = static_cast<const SwDocDisplayItem*>(
GetOldItem(GetItemSet(), FN_PARAM_DOCDISP)); GetOldItem(GetItemSet(), FN_PARAM_DOCDISP));
...@@ -1417,6 +1425,10 @@ void SwShdwCrsrOptionsTabPage::Reset( const SfxItemSet* rSet ) ...@@ -1417,6 +1425,10 @@ void SwShdwCrsrOptionsTabPage::Reset( const SfxItemSet* rSet )
m_pCrsrInProtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue()); m_pCrsrInProtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
m_pCrsrInProtCB->SaveValue(); m_pCrsrInProtCB->SaveValue();
if (rSet->GetItemState(FN_PARAM_IGNORE_PROTECTED, false, &pItem) == SfxItemState::SET)
m_pIgnoreProtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
m_pIgnoreProtCB->SaveValue();
const SwDocDisplayItem* pDocDisplayAttr = 0; const SwDocDisplayItem* pDocDisplayAttr = 0;
rSet->GetItemState( FN_PARAM_DOCDISP, false, rSet->GetItemState( FN_PARAM_DOCDISP, false,
......
...@@ -108,6 +108,7 @@ SfxItemSet* SwModule::CreateItemSet( sal_uInt16 nId ) ...@@ -108,6 +108,7 @@ SfxItemSet* SwModule::CreateItemSet( sal_uInt16 nId )
SID_HTML_MODE, SID_HTML_MODE, SID_HTML_MODE, SID_HTML_MODE,
FN_PARAM_SHADOWCURSOR, FN_PARAM_SHADOWCURSOR, FN_PARAM_SHADOWCURSOR, FN_PARAM_SHADOWCURSOR,
FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED,
FN_PARAM_IGNORE_PROTECTED, FN_PARAM_IGNORE_PROTECTED,
FN_HSCROLL_METRIC, FN_VSCROLL_METRIC, FN_HSCROLL_METRIC, FN_VSCROLL_METRIC,
SID_ATTR_LANGUAGE, SID_ATTR_LANGUAGE, SID_ATTR_LANGUAGE, SID_ATTR_LANGUAGE,
SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE,
...@@ -123,6 +124,7 @@ SfxItemSet* SwModule::CreateItemSet( sal_uInt16 nId ) ...@@ -123,6 +124,7 @@ SfxItemSet* SwModule::CreateItemSet( sal_uInt16 nId )
{ {
pRet->Put( SwShadowCursorItem( aViewOpt, FN_PARAM_SHADOWCURSOR )); pRet->Put( SwShadowCursorItem( aViewOpt, FN_PARAM_SHADOWCURSOR ));
pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea())); pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea()));
pRet->Put(SfxBoolItem(FN_PARAM_IGNORE_PROTECTED, aViewOpt.IsIgnoreProtectedArea()));
} }
if( pAppView ) if( pAppView )
...@@ -409,6 +411,9 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) ...@@ -409,6 +411,9 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
aViewOpt.SetCursorInProtectedArea(static_cast<const SfxBoolItem*>(pItem)->GetValue()); aViewOpt.SetCursorInProtectedArea(static_cast<const SfxBoolItem*>(pItem)->GetValue());
} }
if (rSet.GetItemState(FN_PARAM_IGNORE_PROTECTED, false, &pItem) == SfxItemState::SET)
aViewOpt.SetIgnoreProtectedArea(static_cast<const SfxBoolItem*>(pItem)->GetValue());
// set elements for the current view and shell // set elements for the current view and shell
ApplyUsrPref( aViewOpt, pAppView, bTextDialog? VIEWOPT_DEST_TEXT : VIEWOPT_DEST_WEB); ApplyUsrPref( aViewOpt, pAppView, bTextDialog? VIEWOPT_DEST_TEXT : VIEWOPT_DEST_WEB);
} }
......
...@@ -458,9 +458,10 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames() ...@@ -458,9 +458,10 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames()
{ {
"DirectCursor/UseDirectCursor", // 0 "DirectCursor/UseDirectCursor", // 0
"DirectCursor/Insert", // 1 "DirectCursor/Insert", // 1
"Option/ProtectedArea" // 2 "Option/ProtectedArea", // 2
"Option/IgnoreProtectedArea" // 3
}; };
const int nCount = 3; const int nCount = SAL_N_ELEMENTS(aPropNames);
Sequence<OUString> aNames(nCount); Sequence<OUString> aNames(nCount);
OUString* pNames = aNames.getArray(); OUString* pNames = aNames.getArray();
for(int i = 0; i < nCount; i++) for(int i = 0; i < nCount; i++)
...@@ -493,6 +494,7 @@ void SwCursorConfig::ImplCommit() ...@@ -493,6 +494,7 @@ void SwCursorConfig::ImplCommit()
case 0: pValues[nProp] <<= rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor", case 0: pValues[nProp] <<= rParent.IsShadowCursor(); break;// "DirectCursor/UseDirectCursor",
case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert", case 1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode(); break;// "DirectCursor/Insert",
case 2: pValues[nProp] <<= rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea" case 2: pValues[nProp] <<= rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
case 3: pValues[nProp] <<= rParent.IsIgnoreProtectedArea(); break; // "Option/IgnoreProtectedArea"
} }
} }
PutProperties(aNames, aValues); PutProperties(aNames, aValues);
...@@ -522,6 +524,7 @@ void SwCursorConfig::Load() ...@@ -522,6 +524,7 @@ void SwCursorConfig::Load()
case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor", case 0: rParent.SetShadowCursor(bSet); break;// "DirectCursor/UseDirectCursor",
case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert", case 1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;// "DirectCursor/Insert",
case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea" case 2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
case 3: rParent.SetIgnoreProtectedArea(bSet); break; // "Option/IgnoreProtectedArea"
} }
} }
} }
......
...@@ -267,6 +267,7 @@ class SwShdwCrsrOptionsTabPage : public SfxTabPage ...@@ -267,6 +267,7 @@ class SwShdwCrsrOptionsTabPage : public SfxTabPage
VclFrame* m_pCursorProtFrame; VclFrame* m_pCursorProtFrame;
CheckBox* m_pCrsrInProtCB; CheckBox* m_pCrsrInProtCB;
CheckBox* m_pIgnoreProtCB;
CheckBox* m_pMathBaselineAlignmentCB; CheckBox* m_pMathBaselineAlignmentCB;
......
...@@ -461,7 +461,7 @@ ...@@ -461,7 +461,7 @@
<property name="row_spacing">6</property> <property name="row_spacing">6</property>
<child> <child>
<object class="GtkCheckButton" id="cursorinprot"> <object class="GtkCheckButton" id="cursorinprot">
<property name="label" translatable="yes">Enable</property> <property name="label" translatable="yes">Enable cursor</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
...@@ -471,8 +471,20 @@ ...@@ -471,8 +471,20 @@
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">0</property> <property name="top_attach">0</property>
<property name="width">1</property> </packing>
<property name="height">1</property> </child>
<child>
<object class="GtkCheckButton" id="ignoreprot">
<property name="label" translatable="yes">Ignore protection</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -483,7 +495,7 @@ ...@@ -483,7 +495,7 @@
<object class="GtkLabel" id="cursoropt"> <object class="GtkLabel" id="cursoropt">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Cursor in Protected Areas</property> <property name="label" translatable="yes">Protected Areas</property>
<attributes> <attributes>
<attribute name="weight" value="bold"/> <attribute name="weight" value="bold"/>
</attributes> </attributes>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment