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

New commits:
commit 45e66d20380e9facff62e8a504c8b54f49ebbefe
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Apr 6 20:56:00 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Apr 6 21:27:30 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

diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx
index 72f736ce406b..2ce16aa16de8 100644
--- a/cui/source/options/optsave.cxx
+++ b/cui/source/options/optsave.cxx
@@ -29,6 +29,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 <unotools/optionsdlg.hxx>
@@ -69,6 +70,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"))
@@ -215,6 +217,13 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet )
 {
     bool bModified = false;
     SvtSaveOptions aSaveOpt;
+    if (m_xLoadViewPosAnyUserCB->get_state_changed_from_saved())
+    {
+        std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
+            comphelper::ConfigurationChanges::create());
+        
officecfg::Office::Common::Load::ViewPositionForAnyUser::set(m_xLoadViewPosAnyUserCB->get_active(),
 pBatch);
+        pBatch->commit();
+    }
     if(m_xLoadUserSettingsCB->get_state_changed_from_saved())
     {
         aSaveOpt.SetLoadUserSettings(m_xLoadUserSettingsCB->get_active());
@@ -353,6 +362,9 @@ static bool isODFFormat( const OUString& sFilter )
 void SvxSaveTabPage::Reset( const SfxItemSet* )
 {
     SvtSaveOptions aSaveOpt;
+    
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(aSaveOpt.IsLoadUserSettings());
     m_xLoadUserSettingsCB->save_state();
     
m_xLoadUserSettingsCB->set_sensitive(!aSaveOpt.IsReadOnly(SvtSaveOptions::EOption::UseUserData));
diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx
index 4314bdda1ddf..f412054ae600 100644
--- a/cui/source/options/optsave.hxx
+++ b/cui/source/options/optsave.hxx
@@ -45,6 +45,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 e9a090d45091..c95efcfc68cc 100644
--- a/cui/uiconfig/ui/optsavepage.ui
+++ b/cui/uiconfig/ui/optsavepage.ui
@@ -61,6 +61,21 @@
                     <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="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index f04172b3ef6d..3fdf08d9e19a 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -2503,6 +2503,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 296140abbae7..03df8259d09f 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1166,6 +1166,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