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

Mike Kaganski mike.kaganski at collabora.com
Mon Nov 21 15:29:46 UTC 2016


 sw/inc/cmdid.h                              |    1 -
 sw/inc/viewopt.hxx                          |   11 +----------
 sw/qa/extras/uiwriter/uiwriter.cxx          |    8 +++-----
 sw/source/core/crsr/crsrsh.cxx              |    2 +-
 sw/source/ui/config/optpage.cxx             |   13 -------------
 sw/source/uibase/app/appopt.cxx             |    7 +------
 sw/source/uibase/config/usrpref.cxx         |   15 ++++++---------
 sw/source/uibase/config/viewopt.cxx         |   17 +++++++++++++++++
 sw/source/uibase/inc/optpage.hxx            |    1 -
 sw/uiconfig/swriter/ui/optformataidspage.ui |   14 --------------
 10 files changed, 29 insertions(+), 60 deletions(-)

New commits:
commit efbf399e773c6fc04496331b6ff1efde54bd4f9e
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Fri Nov 18 22:41:13 2016 +0300

    related: tdf#90362: remove option from Formatting Aids
    
    The option to ignore protection breaks expected functionality
    (protection, including sections protected with password), and may
    cause problems mentioned in original bug. This only should be used
    in specific recovery situations.
    
    Moving it from user-visible page to Expert Configuration.
    (Previously, changing it in Expert Configuration hadn't effect.)
    
    Change-Id: Ice2f20200584acd6b476e002eb783820fa823611
    Reviewed-on: https://gerrit.libreoffice.org/30968
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index b3451c9..cf15543 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -786,7 +786,6 @@
 #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 63ba55c..39e30fd 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -74,7 +74,6 @@ enum class ViewOptCoreFlags2 {
     CursorInProt      = 0x0008,
     PdfExport         = 0x0010,
     Printing          = 0x0020,
-    IgnoreProt        = 0x0040
 };
 namespace o3tl {
     template<> struct typed_flags<ViewOptCoreFlags2> : is_typed_flags<ViewOptCoreFlags2, 0x007f> {};
@@ -358,15 +357,7 @@ public:
     inline void SetCursorInProtectedArea(bool b)
         { b ? (m_nCore2Options |= ViewOptCoreFlags2::CursorInProt) : (m_nCore2Options &= ~ViewOptCoreFlags2::CursorInProt);}
 
-    bool IsIgnoreProtectedArea() const
-    {
-        return bool(m_nCore2Options & ViewOptCoreFlags2::IgnoreProt);
-    }
-
-    void SetIgnoreProtectedArea(bool bSet)
-    {
-        bSet ? (m_nCore2Options |= ViewOptCoreFlags2::IgnoreProt) : (m_nCore2Options &= ~ViewOptCoreFlags2::IgnoreProt);
-    }
+    static bool IsIgnoreProtectedArea();
 
     inline bool IsPDFExport() const
         {return bool(m_nCore2Options & ViewOptCoreFlags2::PdfExport); }
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 4c12fc3..46fd478 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -95,6 +95,7 @@
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/dispatch.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <comphelper/configurationhelper.hxx>
 #include <config_features.h>
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
@@ -3017,11 +3018,8 @@ void SwUiWriterTest::testTdf90362()
     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);
+    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());
 }
 
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 480c80e..69ca21f 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3060,7 +3060,7 @@ bool SwCursorShell::HasReadonlySel(bool bAnnotationMode) const
     // If protected area is to be ignored, then selections are never read-only.
     if ((IsReadOnlyAvailable() || GetViewOptions()->IsFormView() ||
         GetDoc()->GetDocumentSettingManager().get( DocumentSettingId::PROTECT_FORM )) &&
-        !GetViewOptions()->IsIgnoreProtectedArea())
+        !SwViewOption::IsIgnoreProtectedArea())
     {
         if ( m_pTableCursor != nullptr )
         {
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index e4c17d0..7a24b7d 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -1331,7 +1331,6 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage( vcl::Window* pParent,
 
     get(m_pCursorProtFrame, "crsrprotframe");
     get(m_pCursorInProtCB, "cursorinprot");
-    get(m_pIgnoreProtCB, "ignoreprot");
 
     get(m_pMathBaselineAlignmentCB, "mathbaseline");
 
@@ -1365,7 +1364,6 @@ SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage( vcl::Window* pParent,
 
         m_pCursorProtFrame->Hide();
         m_pCursorInProtCB->Hide();
-        m_pIgnoreProtCB->Hide();
     }
 }
 
@@ -1393,7 +1391,6 @@ void SwShdwCursorOptionsTabPage::dispose()
     m_pFillSpaceRB.clear();
     m_pCursorProtFrame.clear();
     m_pCursorInProtCB.clear();
-    m_pIgnoreProtCB.clear();
     m_pMathBaselineAlignmentCB.clear();
     SfxTabPage::dispose();
 }
@@ -1447,12 +1444,6 @@ bool SwShdwCursorOptionsTabPage::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));
 
@@ -1503,10 +1494,6 @@ void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
         m_pCursorInProtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
     m_pCursorInProtCB->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 = nullptr;
 
     rSet->GetItemState( FN_PARAM_DOCDISP, false,
diff --git a/sw/source/uibase/app/appopt.cxx b/sw/source/uibase/app/appopt.cxx
index 7f90721..e30b2a4 100644
--- a/sw/source/uibase/app/appopt.cxx
+++ b/sw/source/uibase/app/appopt.cxx
@@ -108,7 +108,6 @@ 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,
@@ -124,7 +123,6 @@ SfxItemSet*  SwModule::CreateItemSet( sal_uInt16 nId )
     {
         pRet->Put( SwShadowCursorItem( aViewOpt ));
         pRet->Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea()));
-        pRet->Put(SfxBoolItem(FN_PARAM_IGNORE_PROTECTED, aViewOpt.IsIgnoreProtectedArea()));
     }
 
     if( pAppView )
@@ -413,10 +411,7 @@ 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
+    // set elements for the current view and shell
     ApplyUsrPref( aViewOpt, pAppView, bTextDialog? SvViewOpt::DestText : SvViewOpt::DestWeb);
 }
 
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index 81a1b78..bd44ecc 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -468,7 +468,6 @@ Sequence<OUString> SwCursorConfig::GetPropertyNames()
         "DirectCursor/UseDirectCursor", // 0
         "DirectCursor/Insert",          // 1
         "Option/ProtectedArea",         // 2
-        "Option/IgnoreProtectedArea"    // 3
     };
     const int nCount = SAL_N_ELEMENTS(aPropNames);
     Sequence<OUString> aNames(nCount);
@@ -500,10 +499,9 @@ void SwCursorConfig::ImplCommit()
     {
         switch(nProp)
         {
-            case  0: pValues[nProp] <<= rParent.IsShadowCursor(); break;//  "DirectCursor/UseDirectCursor",
-            case  1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCursorFillMode();   break;//  "DirectCursor/Insert",
-            case  2: pValues[nProp] <<= rParent.IsCursorInProtectedArea(); break;// "Option/ProtectedArea"
-            case  3: pValues[nProp] <<= rParent.IsIgnoreProtectedArea(); break; // "Option/IgnoreProtectedArea"
+            case  0: pValues[nProp] <<= rParent.IsShadowCursor();                   break; // "DirectCursor/UseDirectCursor",
+            case  1: pValues[nProp] <<= (sal_Int32)rParent.GetShdwCursorFillMode(); break; // "DirectCursor/Insert",
+            case  2: pValues[nProp] <<= rParent.IsCursorInProtectedArea();          break; // "Option/ProtectedArea"
         }
     }
     PutProperties(aNames, aValues);
@@ -530,10 +528,9 @@ void SwCursorConfig::Load()
                     pValues[nProp] >>= nSet;
                 switch(nProp)
                 {
-                    case  0: rParent.SetShadowCursor(bSet);         break;//  "DirectCursor/UseDirectCursor",
-                    case  1: rParent.SetShdwCursorFillMode((sal_uInt8)nSet); break;//  "DirectCursor/Insert",
-                    case  2: rParent.SetCursorInProtectedArea(bSet); break;// "Option/ProtectedArea"
-                    case  3: rParent.SetIgnoreProtectedArea(bSet); break; // "Option/IgnoreProtectedArea"
+                    case  0: rParent.SetShadowCursor(bSet);                  break; // "DirectCursor/UseDirectCursor",
+                    case  1: rParent.SetShdwCursorFillMode((sal_uInt8)nSet); break; // "DirectCursor/Insert",
+                    case  2: rParent.SetCursorInProtectedArea(bSet);         break; // "Option/ProtectedArea"
                 }
             }
         }
diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx
index 0be3a79..bbfe620 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -40,6 +40,7 @@
 
 #include <editeng/acorrcfg.hxx>
 #include <comphelper/lok.hxx>
+#include <comphelper/configurationlistener.hxx>
 
 #ifdef DBG_UTIL
 bool SwViewOption::m_bTest9 = false;        //DrawingLayerNotLoading
@@ -561,4 +562,20 @@ bool SwViewOption::IsAppearanceFlag(ViewOptFlags nFlag)
     return bool(m_nAppearanceFlags & nFlag);
 }
 
+namespace{
+rtl::Reference<comphelper::ConfigurationListener> const & getWCOptionListener()
+{
+    static rtl::Reference<comphelper::ConfigurationListener> xListener;
+    if (!xListener.is())
+        xListener.set(new comphelper::ConfigurationListener("/org.openoffice.Office.Writer/Cursor/Option"));
+    return xListener;
+}
+}
+
+bool SwViewOption::IsIgnoreProtectedArea()
+{
+    static comphelper::ConfigurationListenerProperty<bool> gIgnoreProtectedArea(getWCOptionListener(), "IgnoreProtectedArea");
+    return gIgnoreProtectedArea.get();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/optpage.hxx b/sw/source/uibase/inc/optpage.hxx
index cfc6bf1..a4022db 100644
--- a/sw/source/uibase/inc/optpage.hxx
+++ b/sw/source/uibase/inc/optpage.hxx
@@ -255,7 +255,6 @@ class SwShdwCursorOptionsTabPage : public SfxTabPage
 
     VclPtr<VclFrame> m_pCursorProtFrame;
     VclPtr<CheckBox> m_pCursorInProtCB;
-    VclPtr<CheckBox> m_pIgnoreProtCB;
 
     VclPtr<CheckBox> m_pMathBaselineAlignmentCB;
 
diff --git a/sw/uiconfig/swriter/ui/optformataidspage.ui b/sw/uiconfig/swriter/ui/optformataidspage.ui
index 33c767c..0af1f6e 100644
--- a/sw/uiconfig/swriter/ui/optformataidspage.ui
+++ b/sw/uiconfig/swriter/ui/optformataidspage.ui
@@ -505,20 +505,6 @@
                             <property name="top_attach">0</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>
                     </child>
                   </object>


More information about the Libreoffice-commits mailing list