[ooo-build-commit] Branch 'ooo-build-3-1-1' - patches/dev300
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Sep 25 19:14:03 PDT 2009
patches/dev300/apply | 3
patches/dev300/calc-selection-protected-cells.diff | 155 +++++++++++++++++++++
2 files changed, 158 insertions(+)
New commits:
commit 48fc62576c2c4797ac823e4818d92a50b79d52c3
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Fri Sep 25 22:05:11 2009 -0400
[experimental] Disable context menu on non-selectable cells.
* patches/dev300/apply: apply this new patch.
* patches/dev300/calc-selection-protected-cells.diff: disable
selection of non-selectable cells via right-click, when the
sheet is protected and the sheet protection option specifies
that the protected cells be non-selectable. (n#542024)
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 982df73..fdddca7 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -3419,6 +3419,9 @@ calc-insert-over-merged-cells.diff, n#540923, i#7500, kohei
# 2003 and 2007 happy.
calc-combo-listbox-export-fix.diff, n#540566, noelp
+# Disable context menu on non-selectable cells.
+calc-selection-protected-cells.diff, n#542024, kohei
+
[ AutoLayout ]
sd-layoutcode.diff, cocofan
offapi-layoutcode.diff, cocofan
diff --git a/patches/dev300/calc-selection-protected-cells.diff b/patches/dev300/calc-selection-protected-cells.diff
new file mode 100644
index 0000000..fa7a882
--- /dev/null
+++ b/patches/dev300/calc-selection-protected-cells.diff
@@ -0,0 +1,155 @@
+diff --git sc/source/ui/inc/gridwin.hxx sc/source/ui/inc/gridwin.hxx
+index 3ab93fd..29cd088 100644
+--- sc/source/ui/inc/gridwin.hxx
++++ sc/source/ui/inc/gridwin.hxx
+@@ -345,7 +345,7 @@ private:
+
+ void PasteSelection( const Point& rPosPixel );
+
+- void SelectForContextMenu( const Point& rPosPixel );
++ void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
+
+ void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
+ struct RectangleConverter {
+diff --git sc/source/ui/inc/hdrcont.hxx sc/source/ui/inc/hdrcont.hxx
+index 20cc822..497140f 100644
+--- sc/source/ui/inc/hdrcont.hxx
++++ sc/source/ui/inc/hdrcont.hxx
+@@ -80,7 +80,7 @@ private:
+
+ long GetScrPos( SCCOLROW nEntryNo );
+ SCCOLROW GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder );
+-
++ bool IsSelectionAllowed(SCCOLROW nPos) const;
+ void ShowDragHelp();
+
+ void DoPaint( SCCOLROW nStart, SCCOLROW nEnd );
+diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
+index adb2f20..1079b9d 100644
+--- sc/source/ui/view/gridwin.cxx
++++ sc/source/ui/view/gridwin.cxx
+@@ -2753,9 +2753,32 @@ void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt )
+
+ if ( bMouse )
+ {
++ SCsCOL nCellX = -1;
++ SCsROW nCellY = -1;
++ pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY);
++ ScDocument* pDoc = pViewData->GetDocument();
++ SCTAB nTab = pViewData->GetTabNo();
++ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
++ bool bSelectAllowed = true;
++ if ( pProtect && pProtect->isProtected() )
++ {
++ // This sheet is protected. Check if a context menu is allowed on this cell.
++ bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HASATTR_PROTECTED);
++ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
++ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
++
++ if (bCellProtected)
++ bSelectAllowed = bSelProtected;
++ else
++ bSelectAllowed = bSelUnprotected;
++ }
++ if (!bSelectAllowed)
++ // Selecting this cell is not allowed, neither is context menu.
++ return;
++
+ // #i18735# First select the item under the mouse pointer.
+ // This can change the selection, and the view state (edit mode, etc).
+- SelectForContextMenu( aPosPixel );
++ SelectForContextMenu( aPosPixel, nCellX, nCellY );
+ }
+
+ BOOL bDone = FALSE;
+@@ -2850,15 +2873,12 @@ void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt )
+ }
+ }
+
+-void ScGridWindow::SelectForContextMenu( const Point& rPosPixel )
++void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY )
+ {
+ // #i18735# if the click was outside of the current selection,
+ // the cursor is moved or an object at the click position selected.
+ // (see SwEditWin::SelectMenuPosition in Writer)
+
+- SCsCOL nCellX;
+- SCsROW nCellY;
+- pViewData->GetPosFromPixel( rPosPixel.X(), rPosPixel.Y(), eWhich, nCellX, nCellY );
+ ScTabView* pView = pViewData->GetView();
+ ScDrawView* pDrawView = pView->GetScDrawView();
+
+diff --git sc/source/ui/view/hdrcont.cxx sc/source/ui/view/hdrcont.cxx
+index 89e871c..5cfe8f8 100644
+--- sc/source/ui/view/hdrcont.cxx
++++ sc/source/ui/view/hdrcont.cxx
+@@ -47,6 +47,7 @@
+ #include "scmod.hxx" // Optionen
+ #include "inputopt.hxx" // Optionen
+ #include "gridmerg.hxx"
++#include "document.hxx"
+
+ // -----------------------------------------------------------------------
+
+@@ -655,6 +656,39 @@ SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder )
+ return nHitNo;
+ }
+
++bool ScHeaderControl::IsSelectionAllowed(SCCOLROW nPos) const
++{
++ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
++ if (!pViewSh)
++ return false;
++
++ ScViewData* pViewData = pViewSh->GetViewData();
++ USHORT nTab = pViewData->GetTabNo();
++ ScDocument* pDoc = pViewData->GetDocument();
++ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
++ bool bSelectAllowed = true;
++ if ( pProtect && pProtect->isProtected() )
++ {
++ // This sheet is protected. Check if a context menu is allowed on this cell.
++ bool bCellsProtected = false;
++ if (bVertical)
++ // row header
++ bCellsProtected = pDoc->HasAttrib(0, nPos, nTab, MAXCOL, nPos, nTab, HASATTR_PROTECTED);
++ else
++ // column header
++ bCellsProtected = pDoc->HasAttrib(nPos, 0, nTab, nPos, MAXROW, nTab, HASATTR_PROTECTED);
++
++ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
++ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
++
++ if (bCellsProtected)
++ bSelectAllowed = bSelProtected;
++ else
++ bSelectAllowed = bSelUnprotected;
++ }
++ return bSelectAllowed;
++}
++
+ void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
+ {
+ if (IsDisabled())
+@@ -665,6 +699,8 @@ void __EXPORT ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
+
+ BOOL bFound;
+ SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
++ if (!IsSelectionAllowed(nHitNo))
++ return;
+
+ if ( bFound && rMEvt.IsLeft() && ResizeAllowed() )
+ {
+@@ -848,8 +884,11 @@ void __EXPORT ScHeaderControl::Command( const CommandEvent& rCEvt )
+ MouseEvent aMEvt( rCEvt.GetMousePosPixel() );
+ BOOL bBorder;
+ SCCOLROW nPos = GetMousePos( aMEvt, bBorder );
+- USHORT nTab = pViewData->GetTabNo();
++ if (!IsSelectionAllowed(nPos))
++ // Selecting this cell is not allowed, neither is context menu.
++ return;
+
++ SCTAB nTab = pViewData->GetTabNo();
+ ScRange aNewRange;
+ if ( bVertical )
+ aNewRange = ScRange( 0, sal::static_int_cast<SCROW>(nPos), nTab,
More information about the ooo-build-commit
mailing list