cui/source/options/optsave.cxx                             |    9 ++++++
 cui/source/options/optsave.hxx                             |    1 
 cui/uiconfig/ui/optsavepage.ui                             |   19 +++++++++++++
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    8 +++++
 sw/source/uibase/uiview/view.cxx                           |    4 ++
 5 files changed, 41 insertions(+)

New commits:
commit d57abff54db6860c3e263c8874c6b606e1ba1088
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Apr 6 20:56:00 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Apr 11 20:16:28 2023 +0200

    officecfg,cui,sw: add Common::Load::ViewPositionForAnyUser
    
    Add setting Office::Common::Load::ViewPositionForAnyUser which if
    enabled skips the user name matching against meta.xml that sw does
    before restoring a view position stored as ViewTop/ViewLeft/etc. in
    settings.xml in an ODF file.
    
    This is particularly useful if the user disables the "ApplyUserData"
    in Document->Properties->General, which made restoring view position
    impossible.
    
    Change-Id: Ie3ced3c4ad20a35eb8453ad1521c787b0b0c8458
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150113
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index 0abadfd03e92..3fbeebf4543d 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/container/XContainerQuery.hpp>
 #include <com/sun/star/container/XEnumeration.hpp>
 #include <com/sun/star/beans/PropertyValue.hpp>
+#include <officecfg/Office/Common.hxx>
 #include <sfx2/sfxsids.hrc>
 #include <sfx2/docfilt.hxx>
 #include <svtools/restartdialog.hxx>
@@ -78,6 +79,7 @@ SvxSaveTabPage_Impl::SvxSaveTabPage_Impl() : bInitialized( 
false )
 SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* 
pController, const SfxItemSet& rCoreSet)
     : SfxTabPage( pPage, pController, "cui/ui/optsavepage.ui", "OptSavePage", 
&rCoreSet )
     , pImpl(new SvxSaveTabPage_Impl)
+    , m_xLoadViewPosAnyUserCB(m_xBuilder->weld_check_button("load_anyuser"))
     , m_xLoadUserSettingsCB(m_xBuilder->weld_check_button("load_settings"))
     , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button("load_docprinter"))
     , m_xDocInfoCB(m_xBuilder->weld_check_button("docinfo"))
@@ -228,6 +230,10 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet )
 {
     auto xChanges = comphelper::ConfigurationChanges::create();
     bool bModified = false, bRequestRestart = false;
+    if (m_xLoadViewPosAnyUserCB->get_state_changed_from_saved())
+    {
+        
officecfg::Office::Common::Load::ViewPositionForAnyUser::set(m_xLoadViewPosAnyUserCB->get_active(),
 xChanges);
+    }
     if(m_xLoadUserSettingsCB->get_state_changed_from_saved())
         
officecfg::Office::Common::Load::UserDefinedSettings::set(m_xLoadUserSettingsCB->get_active(),
 xChanges);
 
@@ -371,6 +377,9 @@ static bool isODFFormat( std::u16string_view sFilter )
 
 void SvxSaveTabPage::Reset( const SfxItemSet* )
 {
+    
m_xLoadViewPosAnyUserCB->set_active(officecfg::Office::Common::Load::ViewPositionForAnyUser::get());
+    m_xLoadViewPosAnyUserCB->save_state();
+    
m_xLoadViewPosAnyUserCB->set_sensitive(!officecfg::Office::Common::Load::ViewPositionForAnyUser::isReadOnly());
     
m_xLoadUserSettingsCB->set_active(officecfg::Office::Common::Load::UserDefinedSettings::get());
     m_xLoadUserSettingsCB->save_state();
     
m_xLoadUserSettingsCB->set_sensitive(!officecfg::Office::Common::Load::UserDefinedSettings::isReadOnly());
diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx
index 4ec3b1ddada5..1bc047985330 100644
--- a/cui/source/options/optsave.hxx
+++ b/cui/source/options/optsave.hxx
@@ -41,6 +41,7 @@ class SvxSaveTabPage : public SfxTabPage
 private:
     std::unique_ptr<SvxSaveTabPage_Impl>    pImpl;
 
+    std::unique_ptr<weld::CheckButton> m_xLoadViewPosAnyUserCB;
     std::unique_ptr<weld::CheckButton> m_xLoadUserSettingsCB;
     std::unique_ptr<weld::CheckButton> m_xLoadDocPrinterCB;
     std::unique_ptr<weld::CheckButton> m_xDocInfoCB;
diff --git a/cui/uiconfig/ui/optsavepage.ui b/cui/uiconfig/ui/optsavepage.ui
index d9c1ce1235a2..be612ec3b775 100644
--- a/cui/uiconfig/ui/optsavepage.ui
+++ b/cui/uiconfig/ui/optsavepage.ui
@@ -67,6 +67,25 @@
                 <property name="top_attach">0</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkCheckButton" id="load_anyuser">
+                <property name="label" translatable="yes" 
context="optsavepage|load_anyuser">Load view position with the document even if 
it was saved by a different user</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="draw_indicator">True</property>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="load_anyuser-atkobject">
+                    <property name="AtkObject::accessible-description" 
translatable="yes" context="load_anyuser">Loads the view position settings 
saved in a document with the document even if it was saved by a different 
user.</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
+              </packing>
+            </child>
           </object>
         </child>
         <child type="label">
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 6702c8499315..9beda4a62c81 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2565,6 +2565,14 @@
         </info>
         <value>true</value>
       </prop>
+      <prop oor:name="ViewPositionForAnyUser" oor:type="xs:boolean" 
oor:nillable="false">
+        <info>
+          <desc>Determines if the view position of the document is loaded with
+          a document even if it was saved by a different user.
+          </desc>
+        </info>
+        <value>false</value>
+      </prop>
       <prop oor:name="ShowOfficeUpdateDialog" oor:type="xs:boolean" 
oor:nillable="false">
         <info>
           <desc>Specifies whether the office update dialog should be shown in
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 219958ec8517..2ef8ef1a70a5 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1201,6 +1201,10 @@ void SwView::WriteUserData( OUString &rUserData, bool 
bBrowse )
 
 static bool lcl_IsOwnDocument( SwView& rView )
 {
+    if (::officecfg::Office::Common::Load::ViewPositionForAnyUser::get())
+    {
+        return true;
+    }
     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
         rView.GetDocShell()->GetModel(), uno::UNO_QUERY_THROW);
     uno::Reference<document::XDocumentProperties> xDocProps

Reply via email to