[Libreoffice-commits] core.git: officecfg/registry sw/inc sw/qa sw/source sw/uiconfig

Miklos Vajna vmiklos at collabora.co.uk
Tue Apr 7 04:44:58 PDT 2015


 officecfg/registry/schema/org/openoffice/Office/Writer.xcs |    7 ++++
 sw/inc/cmdid.h                                             |    1 
 sw/inc/viewopt.hxx                                         |   15 ++++++++-
 sw/qa/extras/uiwriter/data/tdf90362.fodt                   |   10 ++++++
 sw/qa/extras/uiwriter/uiwriter.cxx                         |   20 +++++++++++++
 sw/source/core/crsr/crsrsh.cxx                             |    3 +
 sw/source/ui/config/optpage.cxx                            |   12 +++++++
 sw/source/uibase/app/appopt.cxx                            |    5 +++
 sw/source/uibase/config/usrpref.cxx                        |    7 +++-
 sw/source/uibase/inc/optpage.hxx                           |    1 
 sw/uiconfig/swriter/ui/optformataidspage.ui                |   20 ++++++++++---
 11 files changed, 92 insertions(+), 9 deletions(-)

New commits:
commit 4a59caddac55002ccecb6fda538255bfe03c6d2d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 7 09:17:41 2015 +0200

    tdf#90362 sw: config option for ignoring protected areas
    
    Change-Id: Idfa62aa5bbccf62ee85f863150e13f80b8b5db90
    Reviewed-on: https://gerrit.libreoffice.org/15181
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index 7be5ca5..0b7c99b 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -2359,6 +2359,13 @@
           </info>
           <value>true</value>
         </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 oor:name="Revision">
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index d84496c..dda4a38 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -795,6 +795,7 @@
 #define FN_SHAPE_ENDPOSITION_IN_HORI_L2R   (FN_PARAM2+26)
 #define FN_PARAM_PAM                    (FN_PARAM2+27) /* Point and Mark */
 #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!
 #define FN_STAT_PAGE                (FN_STAT + 1)
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index bae0e1d..87dc830 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -69,6 +69,7 @@ namespace svtools{ class ColorConfig;}
 #define VIEWOPT_CORE2_CRSR_IN_PROT      0x00000008L
 #define VIEWOPT_CORE2_PDF_EXPORT        0x00000010L
 #define VIEWOPT_CORE2_PRINTING          0x00000020L
+#define VIEWOPT_CORE2_IGNORE_PROT       0x00000040L
 
 #define VIEWOPT_2_H_RULER           0x00000400L
 #define VIEWOPT_2_VSCROLLBAR        0x00000800L
@@ -103,7 +104,7 @@ namespace svtools{ class ColorConfig;}
 // Implementation in core/text/txtpaint.cxx.
 extern void SyncVout( const OutputDevice *pOut );
 
-class SwViewOption
+class SW_DLLPUBLIC SwViewOption
 {
     static Color    aDocColor;  // color of document boundaries
     static Color    aDocBoundColor;  // color of document boundaries
@@ -342,6 +343,16 @@ public:
     inline void SetCursorInProtectedArea(bool b)
         { 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
         {return (nCore2Options & VIEWOPT_CORE2_PDF_EXPORT) != 0; }
 
@@ -553,7 +564,7 @@ public:
     static Color&   GetSpellColor();
     static Color&   GetSmarttagColor();
     static Color&   GetShadowColor();
-    SW_DLLPUBLIC static Color&   GetFontColor();
+    static Color&   GetFontColor();
     static Color&   GetFieldShadingsColor();
     static Color&   GetSectionBoundColor();
     static Color&   GetPageBreakColor();
diff --git a/sw/qa/extras/uiwriter/data/tdf90362.fodt b/sw/qa/extras/uiwriter/data/tdf90362.fodt
new file mode 100644
index 0000000..bf74255
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf90362.fodt
@@ -0,0 +1,10 @@
+<?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:oas
 is: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>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index e792e5c..04b7d25 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -88,6 +88,7 @@ public:
     void testCp1000115();
     void testTdf90003();
     void testSearchWithTransliterate();
+    void testTdf90362();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest);
     CPPUNIT_TEST(testReplaceForward);
@@ -121,6 +122,7 @@ public:
     CPPUNIT_TEST(testCp1000115);
     CPPUNIT_TEST(testTdf90003);
     CPPUNIT_TEST(testSearchWithTransliterate);
+    CPPUNIT_TEST(testTdf90362);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -890,6 +892,24 @@ void SwUiWriterTest::testSearchWithTransliterate()
     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_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index c3df6f4..1d19e11 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3022,7 +3022,8 @@ void SwCrsrShell::SetReadOnlyAvailable( bool bFlag )
 bool SwCrsrShell::HasReadonlySel(bool bAnnotationMode) const
 {
     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 )
         {
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index eba0445..30fcf86 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1278,6 +1278,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent,
 
     get(m_pCursorProtFrame, "crsrprotframe");
     get(m_pCrsrInProtCB, "cursorinprot");
+    get(m_pIgnoreProtCB, "ignoreprot");
 
     get(m_pMathBaselineAlignmentCB, "mathbaseline");
 
@@ -1311,6 +1312,7 @@ SwShdwCrsrOptionsTabPage::SwShdwCrsrOptionsTabPage( vcl::Window* pParent,
 
         m_pCursorProtFrame->Hide();
         m_pCrsrInProtCB->Hide();
+        m_pIgnoreProtCB->Hide();
     }
 }
 
@@ -1367,6 +1369,12 @@ bool SwShdwCrsrOptionsTabPage::FillItemSet( SfxItemSet* rSet )
         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*>(
                         GetOldItem(GetItemSet(), FN_PARAM_DOCDISP));
 
@@ -1417,6 +1425,10 @@ void SwShdwCrsrOptionsTabPage::Reset( const SfxItemSet* rSet )
         m_pCrsrInProtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
     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;
 
     rSet->GetItemState( FN_PARAM_DOCDISP, false,
diff --git a/sw/source/uibase/app/appopt.cxx b/sw/source/uibase/app/appopt.cxx
index 5c3ac9b..db3aeb3 100644
--- a/sw/source/uibase/app/appopt.cxx
+++ b/sw/source/uibase/app/appopt.cxx
@@ -108,6 +108,7 @@ SfxItemSet*  SwModule::CreateItemSet( sal_uInt16 nId )
                                     SID_HTML_MODE,          SID_HTML_MODE,
                                     FN_PARAM_SHADOWCURSOR,  FN_PARAM_SHADOWCURSOR,
                                     FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED,
+                                    FN_PARAM_IGNORE_PROTECTED, FN_PARAM_IGNORE_PROTECTED,
                                     FN_HSCROLL_METRIC,      FN_VSCROLL_METRIC,
                                     SID_ATTR_LANGUAGE,      SID_ATTR_LANGUAGE,
                                     SID_ATTR_CHAR_CJK_LANGUAGE,   SID_ATTR_CHAR_CJK_LANGUAGE,
@@ -123,6 +124,7 @@ SfxItemSet*  SwModule::CreateItemSet( sal_uInt16 nId )
     {
         pRet->Put( SwShadowCursorItem( aViewOpt, FN_PARAM_SHADOWCURSOR ));
         pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea()));
+        pRet->Put(SfxBoolItem(FN_PARAM_IGNORE_PROTECTED, aViewOpt.IsIgnoreProtectedArea()));
     }
 
     if( pAppView )
@@ -409,6 +411,9 @@ void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
         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
     ApplyUsrPref( aViewOpt, pAppView, bTextDialog? VIEWOPT_DEST_TEXT : VIEWOPT_DEST_WEB);
 }
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index 757d3fd..566b590 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -458,9 +458,10 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames()
     {
         "DirectCursor/UseDirectCursor", // 0
         "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);
     OUString* pNames = aNames.getArray();
     for(int i = 0; i < nCount; i++)
@@ -493,6 +494,7 @@ void SwCursorConfig::ImplCommit()
             case  0: pValues[nProp] <<= rParent.IsShadowCursor(); break;//  "DirectCursor/UseDirectCursor",
             case  1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCrsrFillMode();   break;//  "DirectCursor/Insert",
             case  2: pValues[nProp] <<= rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
+            case  3: pValues[nProp] <<= rParent.IsIgnoreProtectedArea(); break; // "Option/IgnoreProtectedArea"
         }
     }
     PutProperties(aNames, aValues);
@@ -522,6 +524,7 @@ void SwCursorConfig::Load()
                     case  0: rParent.SetShadowCursor(bSet);         break;//  "DirectCursor/UseDirectCursor",
                     case  1: rParent.SetShdwCrsrFillMode((sal_uInt8)nSet); break;//  "DirectCursor/Insert",
                     case  2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
+                    case  3: rParent.SetIgnoreProtectedArea(bSet); break; // "Option/IgnoreProtectedArea"
                 }
             }
         }
diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx
index 196a540..05789ce 100644
--- a/sw/source/uibase/inc/optpage.hxx
+++ b/sw/source/uibase/inc/optpage.hxx
@@ -267,6 +267,7 @@ class SwShdwCrsrOptionsTabPage : public SfxTabPage
 
     VclFrame* m_pCursorProtFrame;
     CheckBox* m_pCrsrInProtCB;
+    CheckBox* m_pIgnoreProtCB;
 
     CheckBox* m_pMathBaselineAlignmentCB;
 
diff --git a/sw/uiconfig/swriter/ui/optformataidspage.ui b/sw/uiconfig/swriter/ui/optformataidspage.ui
index 85dd592..6424051 100644
--- a/sw/uiconfig/swriter/ui/optformataidspage.ui
+++ b/sw/uiconfig/swriter/ui/optformataidspage.ui
@@ -461,7 +461,7 @@
                         <property name="row_spacing">6</property>
                         <child>
                           <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="can_focus">True</property>
                             <property name="receives_default">False</property>
@@ -471,8 +471,20 @@
                           <packing>
                             <property name="left_attach">0</property>
                             <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
+                          </packing>
+                        </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>
                         </child>
                       </object>
@@ -483,7 +495,7 @@
                   <object class="GtkLabel" id="cursoropt">
                     <property name="visible">True</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>
                       <attribute name="weight" value="bold"/>
                     </attributes>


More information about the Libreoffice-commits mailing list