Hi,

I'm working on fdo#80538 <https://bugs.freedesktop.org/show_bug.cgi?id=80538> (adding an infobar when document is in read-only mode). With the attached patch the infobar is shown when you enable the non-edit mode via toolbar, but I can't get the button to leave read-only mode in there.

Can someone give me a hint what's wrong with my code?

Thanks
Samuel
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index d29222f..3947c75 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -196,6 +196,7 @@ private:
     DECL_LINK( SimpleRefAborted, OUString* );
     DECL_LINK( SimpleRefChange, OUString* );
     DECL_LINK( FormControlActivated, void* );
+    DECL_LINK( ReadOnlyHandler, void * );
 
 protected:
     virtual void    Activate(bool bMDI) SAL_OVERRIDE;
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 53223c4..79be98f 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -38,6 +38,7 @@
 #include "editsh.hxx"
 #include "hints.hxx"
 #include "cellvalue.hxx"
+#include "scresid.hxx"
 #include <svl/sharedstring.hxx>
 
 void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
@@ -116,6 +117,16 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                                                 &aItem, 0L );
 
                     UpdateInputContext();
+                    if (bReadOnly) {
+                        std::vector< PushButton* > aButtons;
+                        PushButton* pBtn = new PushButton( &GetViewFrame()->GetWindow(), ScResId(SCSTR_PAGEBREAKSHELL));
+                        pBtn->SetClickHdl( LINK( this, ScTabViewShell, ReadOnlyHandler ) );
+                        aButtons.push_back( pBtn );
+                        GetViewFrame()->AppendInfoBar("readonly", ScGlobal::GetRscString(STR_READONLYERR), aButtons);
+                    }
+                    else {
+                        GetViewFrame()->RemoveInfoBar("readonly");
+                    }
                 }
                 break;
 
@@ -304,6 +315,14 @@ void ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     SfxViewShell::Notify( rBC, rHint );
 }
 
+
+
+IMPL_LINK_NOARG ( ScTabViewShell, ReadOnlyHandler )
+{
+    return 0;
+}
+
+
 SvxNumberInfoItem* ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, ScViewData* pViewData )
 {
 
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to