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

Oliver Specht oliver.specht at cib.de
Fri Apr 22 13:19:04 UTC 2016


 include/unotools/compatibility.hxx       |    8 ++++++--
 sw/inc/viewsh.hxx                        |    2 ++
 sw/source/core/view/viewsh.cxx           |    7 +++++++
 sw/source/ui/config/optcomp.cxx          |   30 +++++++++++++++++++++++-------
 sw/uiconfig/swriter/ui/optcompatpage.ui  |    1 +
 unotools/source/config/compatibility.cxx |   31 ++++++++++++++++++++++++-------
 6 files changed, 63 insertions(+), 16 deletions(-)

New commits:
commit 8d41866f76ce3909b8d1bba6d0b74c4acb91202b
Author: Oliver Specht <oliver.specht at cib.de>
Date:   Fri Apr 22 11:20:02 2016 +0200

    tdf#81833: form protection can be modified as compatibility option
    
    ProtectForm is supported to prevent editing outside of form controls
    but could only be imported from doc and stored in odt but not changed.
    Now it is part of Writer's compatibility settings dialog.
    
    Change-Id: I7337fb3f0774d3c1d26cd8e1485958399b2a70e2
    Reviewed-on: https://gerrit.libreoffice.org/24294
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Oliver Specht <oliver.specht at cib.de>

diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx
index 554f51e..0cf64fa 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -40,7 +40,8 @@ enum CompatibilityOptions
     COPT_USE_OBJECTPOSITIONING,
     COPT_USE_OUR_TEXTWRAPPING,
     COPT_CONSIDER_WRAPPINGSTYLE,
-    COPT_EXPAND_WORDSPACE
+    COPT_EXPAND_WORDSPACE,
+    COPT_PROTECT_FORM
 };
 
 /*-************************************************************************************************************
@@ -60,6 +61,7 @@ enum CompatibilityOptions
 #define COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING       "UseOurTextWrapping"
 #define COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE    "ConsiderWrappingStyle"
 #define COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE          "ExpandWordSpace"
+#define COMPATIBILITY_PROPERTYNAME_PROTECTFORM              "ProtectForm"
 
 #define COMPATIBILITY_DEFAULT_NAME                          "_default"
 
@@ -147,7 +149,8 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
                          bool bUseObjectPositioning,
                          bool bUseOurTextWrapping,
                          bool bConsiderWrappingStyle,
-                         bool bExpandWordSpace );
+                         bool bExpandWordSpace,
+                         bool bProtectForm );
 
         bool        IsUsePrtDevice() const;
         bool        IsAddSpacing() const;
@@ -160,6 +163,7 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
         bool        IsUseOurTextWrapping() const;
         bool        IsConsiderWrappingStyle() const;
         bool        IsExpandWordSpace() const;
+        bool        IsProtectForm() const;
 
     //  private methods
 
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 498e963..c014cbb 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -417,6 +417,8 @@ public:
 
     void SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesWithManualBreak );
 
+    void SetProtectForm( bool _bProtectForm );
+
     // DOCUMENT COMPATIBILITY FLAGS END
 
     // Calls Idle-formatter of Layout.
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index db4128d..79fc84e 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -907,6 +907,13 @@ void SwViewShell::SetDoNotJustifyLinesWithManualBreak( bool _bDoNotJustifyLinesW
     }
 }
 
+void SwViewShell::SetProtectForm( bool _bProtectForm )
+{
+    IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess();
+    rIDSA.set(DocumentSettingId::PROTECT_FORM, _bProtectForm );
+}
+
+
 void SwViewShell::Reformat()
 {
     SwWait aWait( *GetDoc()->GetDocShell(), true );
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index e475c61..c54be94 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -55,13 +55,14 @@ struct CompatibilityItem
     bool        m_bUseOurTextWrapping;
     bool        m_bConsiderWrappingStyle;
     bool        m_bExpandWordSpace;
+    bool        m_bProtectForm;
     bool        m_bIsDefault;
 
     CompatibilityItem( const OUString& _rName, const OUString& _rModule,
                        bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
                        bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
                        bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
-                       bool _bConsiderWrappingStyle, bool _bExpandWordSpace,
+                       bool _bConsiderWrappingStyle, bool _bExpandWordSpace, bool _bProtectForm,
                        bool _bIsDefault ) :
 
         m_sName                 ( _rName ),
@@ -77,6 +78,7 @@ struct CompatibilityItem
         m_bUseOurTextWrapping   ( _bUseOurTextWrapping ),
         m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
         m_bExpandWordSpace      ( _bExpandWordSpace ),
+        m_bProtectForm          ( _bProtectForm),
         m_bIsDefault            ( _bIsDefault ) {}
 };
 
@@ -101,7 +103,7 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
     get(m_pOptionsLB, "options");
     get(m_pDefaultPB, "default");
 
-    for (sal_Int32 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_EXPAND_WORDSPACE; ++nId)
+    for (sal_Int32 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_PROTECT_FORM; ++nId)
     {
         const OUString sEntry = m_pFormattingLB->GetEntry(nId);
         SvTreeListEntry* pEntry = m_pOptionsLB->SvTreeListBox::InsertEntry( sEntry );
@@ -151,7 +153,8 @@ sal_uLong convertBools2Ulong_Impl
     bool _bUseObjPos,
     bool _bUseOurTextWrapping,
     bool _bConsiderWrappingStyle,
-    bool _bExpandWordSpace
+    bool _bExpandWordSpace,
+    bool _bProtectForm
 )
 {
     sal_uLong nRet = 0;
@@ -189,6 +192,9 @@ sal_uLong convertBools2Ulong_Impl
     nSetBit = nSetBit << 1;
     if ( _bExpandWordSpace )
         nRet |= nSetBit;
+    nSetBit = nSetBit << 1;
+    if ( _bProtectForm )
+        nRet |= nSetBit;
 
     return nRet;
 }
@@ -229,6 +235,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
     bool bUseOurTextWrapping = false;
     bool bConsiderWrappingStyle = false;
     bool bExpandWordSpace = false;
+    bool bProtectForm = false;
     const sal_Int32 nCount = aList.getLength();
     for ( sal_Int32 i = 0; i < nCount; ++i )
     {
@@ -263,6 +270,8 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
                 aValue.Value >>= bConsiderWrappingStyle;
             else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
                 aValue.Value >>= bExpandWordSpace;
+            else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_PROTECTFORM )
+                aValue.Value >>= bProtectForm;
         }
 
         const bool bIsUserEntry = sName == "_user";
@@ -272,7 +281,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
             sName, sModule, bUsePrtMetrics, bAddSpacing,
             bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
             bUseLineSpacing, bAddTableSpacing, bUseObjPos,
-            bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
+            bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm,
             bIsDefaultEntry );
         m_pImpl->m_aList.push_back( aItem );
 
@@ -298,7 +307,7 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
             bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
             bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
             bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
-            bConsiderWrappingStyle, bExpandWordSpace );
+            bConsiderWrappingStyle, bExpandWordSpace, bProtectForm );
         m_pFormattingLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)nOptions) );
     }
 
@@ -341,6 +350,7 @@ IMPL_LINK_NOARG_TYPED(SwCompatibilityOptPage, UseAsDefaultHdl, Button*, void)
                         case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break;
                         case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break;
                         case COPT_EXPAND_WORDSPACE:  pItem->m_bExpandWordSpace = bChecked; break;
+                        case COPT_PROTECT_FORM: pItem->m_bProtectForm = bChecked; break;
                         default:
                         {
                             OSL_FAIL("SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" );
@@ -384,7 +394,8 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
                 rIDocumentSettingAccess.get(DocumentSettingId::USE_FORMER_OBJECT_POS),
                 rIDocumentSettingAccess.get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING),
                 rIDocumentSettingAccess.get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION),
-                !rIDocumentSettingAccess.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK) );
+                !rIDocumentSettingAccess.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK),
+                rIDocumentSettingAccess.get(DocumentSettingId::PROTECT_FORM));
     }
     return nRet;
 }
@@ -400,7 +411,7 @@ void SwCompatibilityOptPage::WriteOptions()
             pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
             pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
             pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
-            pItem->m_bExpandWordSpace );
+            pItem->m_bExpandWordSpace, pItem->m_bProtectForm );
 }
 
 VclPtr<SfxTabPage> SwCompatibilityOptPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
@@ -473,6 +484,11 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
                     m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
                     bModified = true;
                 }
+                else if ( COPT_PROTECT_FORM == nOption )
+                {
+                    m_pWrtShell->SetProtectForm( bChecked );
+                    bModified = true;
+                }
             }
 
             nSavedOptions = nSavedOptions >> 1;
diff --git a/sw/uiconfig/swriter/ui/optcompatpage.ui b/sw/uiconfig/swriter/ui/optcompatpage.ui
index 77fc546..4ba4e48 100644
--- a/sw/uiconfig/swriter/ui/optcompatpage.ui
+++ b/sw/uiconfig/swriter/ui/optcompatpage.ui
@@ -64,6 +64,7 @@
                       <item translatable="yes">Use OpenOffice.org 1.1 text wrapping around objects</item>
                       <item translatable="yes">Consider wrapping style when positioning objects</item>
                       <item translatable="yes">Expand word space on lines with manual line breaks in justified paragraphs</item>
+                      <item translatable="yes">Protect form</item>
                       <item translatable="yes"><User settings></item>
                     </items>
                   </object>
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index 096a7f0..b7b34fa 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -56,8 +56,9 @@ using namespace ::com::sun::star::beans;
 #define PROPERTYNAME_USEOURTEXTWRAP     COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
 #define PROPERTYNAME_CONSIDERWRAPSTYLE  COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
 #define PROPERTYNAME_EXPANDWORDSPACE    COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
+#define PROPERTYNAME_PROTECTFORM        COMPATIBILITY_PROPERTYNAME_PROTECTFORM
 
-#define PROPERTYCOUNT                   13
+#define PROPERTYCOUNT                   14
 
 #define OFFSET_NAME                     0
 #define OFFSET_MODULE                   1
@@ -72,6 +73,7 @@ using namespace ::com::sun::star::beans;
 #define OFFSET_USEOURTEXTWRAPPING       10
 #define OFFSET_CONSIDERWRAPPINGSTYLE    11
 #define OFFSET_EXPANDWORDSPACE          12
+#define OFFSET_PROTECTFORM              13
 
 //  private declarations!
 
@@ -87,7 +89,7 @@ struct SvtCompatibilityEntry
             bNoExtLeading( false ), bUseLineSpacing( false ),
             bAddTableSpacing( false ), bUseObjPos( false ),
             bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
-            bExpandWordSpace( true ) {}
+            bExpandWordSpace( true ), bProtectForm( false ) {}
         SvtCompatibilityEntry(
             const OUString& _rName, const OUString& _rNewModule ) :
                 sName( _rName ), sModule( _rNewModule ),
@@ -96,7 +98,7 @@ struct SvtCompatibilityEntry
                 bNoExtLeading( false ), bUseLineSpacing( false ),
                 bAddTableSpacing( false ), bUseObjPos( false ),
                 bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
-                bExpandWordSpace( true ) {}
+                bExpandWordSpace( true ), bProtectForm( false ) {}
 
         inline void     SetUsePrtMetrics( bool _bSet ) { bUsePrtMetrics = _bSet; }
         inline void     SetAddSpacing( bool _bSet ) { bAddSpacing = _bSet; }
@@ -109,6 +111,7 @@ struct SvtCompatibilityEntry
         inline void     SetUseOurTextWrapping( bool _bSet ) { bUseOurTextWrapping = _bSet; }
         inline void     SetConsiderWrappingStyle( bool _bSet ) { bConsiderWrappingStyle = _bSet; }
         inline void     SetExpandWordSpace( bool _bSet ) { bExpandWordSpace = _bSet; }
+        inline void     SetProtectForm( bool _bSet ) { bProtectForm = _bSet; }
 
     public:
         OUString    sName;
@@ -124,6 +127,7 @@ struct SvtCompatibilityEntry
         bool        bUseOurTextWrapping;
         bool        bConsiderWrappingStyle;
         bool        bExpandWordSpace;
+        bool        bProtectForm;
 };
 
 /*-****************************************************************************************************************
@@ -256,7 +260,8 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
                                                             bool _bUseObjPos,
                                                             bool _bUseOurTextWrapping,
                                                             bool _bConsiderWrappingStyle,
-                                                            bool _bExpandWordSpace );
+                                                            bool _bExpandWordSpace,
+                                                            bool _bProtectForm );
 
         inline bool IsUsePrtDevice() const { return m_aDefOptions.bUsePrtMetrics; }
         inline bool IsAddSpacing() const { return m_aDefOptions.bAddSpacing; }
@@ -269,6 +274,7 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
         inline bool IsUseOurTextWrapping() const { return m_aDefOptions.bUseOurTextWrapping; }
         inline bool IsConsiderWrappingStyle() const { return m_aDefOptions.bConsiderWrappingStyle; }
         inline bool IsExpandWordSpace() const { return m_aDefOptions.bExpandWordSpace; }
+        inline bool IsProtectForm() const { return m_aDefOptions.bProtectForm; }
 
     //  private methods
 
@@ -431,6 +437,7 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
         lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1      ].Name = sNode + PROPERTYNAME_USEOURTEXTWRAP;
         lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1   ].Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE;
         lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1         ].Name = sNode + PROPERTYNAME_EXPANDWORDSPACE;
+        lPropertyValues[ OFFSET_PROTECTFORM - 1             ].Name = sNode + PROPERTYNAME_PROTECTFORM;
 
         lPropertyValues[ OFFSET_MODULE - 1                  ].Value <<= aItem.sModule;
         lPropertyValues[ OFFSET_USEPRTMETRICS - 1           ].Value <<= aItem.bUsePrtMetrics;
@@ -444,6 +451,7 @@ void SvtCompatibilityOptions_Impl::ImplCommit()
         lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1      ].Value <<= aItem.bUseOurTextWrapping;
         lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1   ].Value <<= aItem.bConsiderWrappingStyle;
         lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1         ].Value <<= aItem.bExpandWordSpace;
+        lPropertyValues[ OFFSET_PROTECTFORM - 1             ].Value <<= aItem.bProtectForm;
 
         SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
     }
@@ -480,7 +488,8 @@ void SvtCompatibilityOptions_Impl::AppendItem(  const OUString& _sName,
                                                 bool _bUseObjPos,
                                                 bool _bUseOurTextWrapping,
                                                 bool _bConsiderWrappingStyle,
-                                                bool _bExpandWordSpace )
+                                                bool _bExpandWordSpace,
+                                                bool _bProtectForm )
 {
     SvtCompatibilityEntry aItem( _sName, _sModule );
     aItem.SetUsePrtMetrics( _bUsePrtMetrics );
@@ -494,6 +503,7 @@ void SvtCompatibilityOptions_Impl::AppendItem(  const OUString& _sName,
     aItem.SetUseOurTextWrapping( _bUseOurTextWrapping );
     aItem.SetConsiderWrappingStyle( _bConsiderWrappingStyle );
     aItem.SetExpandWordSpace( _bExpandWordSpace );
+    aItem.SetProtectForm( _bProtectForm );
     m_aOptions.AppendEntry( aItem );
 
     // default item reset?
@@ -638,14 +648,15 @@ void SvtCompatibilityOptions::AppendItem( const OUString& sName,
                                           bool bUseObjPos,
                                           bool bUseOurTextWrapping,
                                           bool bConsiderWrappingStyle,
-                                          bool bExpandWordSpace )
+                                          bool bExpandWordSpace,
+                                          bool bProtectForm )
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
     m_pDataContainer->AppendItem(
         sName, sModule, bUsePrtMetrics, bAddSpacing,
         bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
         bUseLineSpacing, bAddTableSpacing, bUseObjPos,
-        bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace );
+        bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace, bProtectForm );
 }
 
 bool SvtCompatibilityOptions::IsUsePrtDevice() const
@@ -714,6 +725,12 @@ bool SvtCompatibilityOptions::IsExpandWordSpace() const
     return m_pDataContainer->IsExpandWordSpace();
 }
 
+bool SvtCompatibilityOptions::IsProtectForm() const
+{
+    MutexGuard aGuard( GetOwnStaticMutex() );
+    return m_pDataContainer->IsProtectForm();
+}
+
 Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions::GetList() const
 {
     MutexGuard aGuard( GetOwnStaticMutex() );


More information about the Libreoffice-commits mailing list