[Libreoffice-commits] .: 4 commits - sc/inc sc/source tools/inc vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Dec 2 18:59:31 PST 2012


 sc/inc/scmod.hxx                          |    7 ++
 sc/source/ui/app/scdll.cxx                |    3 -
 sc/source/ui/app/scmod.cxx                |   86 ++++++++++++++++++++++++++++--
 sc/source/ui/condformat/condformatdlg.cxx |   26 ++-------
 sc/source/ui/condformat/condformatmgr.cxx |    5 +
 sc/source/ui/formdlg/formula.cxx          |    4 -
 sc/source/ui/inc/IAnyRefDialog.hxx        |    2 
 sc/source/ui/inc/anyrefdg.hxx             |   46 +++++++++-------
 sc/source/ui/inc/condformatdlg.hxx        |    4 -
 sc/source/ui/inc/condformatmgr.hxx        |    2 
 sc/source/ui/inc/formula.hxx              |    2 
 sc/source/ui/inc/gridwin.hxx              |    2 
 sc/source/ui/inc/reffact.hxx              |    3 -
 sc/source/ui/inc/tabview.hxx              |    2 
 sc/source/ui/miscdlgs/anyrefdg.cxx        |   43 ++++++++++-----
 sc/source/ui/src/condformatdlg.src        |    2 
 sc/source/ui/view/cellsh1.cxx             |   66 +++++++++++++++++------
 sc/source/ui/view/gridwin.cxx             |   13 ++++
 sc/source/ui/view/reffact.cxx             |   21 -------
 sc/source/ui/view/tabview.cxx             |   11 +++
 sc/source/ui/view/tabview3.cxx            |    2 
 sc/source/ui/view/tabvwsh.cxx             |    3 -
 sc/source/ui/view/tabvwsh4.cxx            |    2 
 sc/source/ui/view/tabvwshc.cxx            |   53 ------------------
 tools/inc/tools/wintypes.hxx              |    1 
 vcl/inc/vcl/window.hxx                    |    5 +
 vcl/source/window/window.cxx              |   11 +++
 vcl/source/window/winproc.cxx             |    4 -
 28 files changed, 268 insertions(+), 163 deletions(-)

New commits:
commit 61d43ea6aaaa953e2243548932e03649bb36f7b4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Oct 21 12:12:33 2012 +0200

    remove commented out methods and parameters in ScAnyRefDlg
    
    Change-Id: Ie9e9baf42c93353a68ef35b456cd621bf42344c5

diff --git a/sc/source/ui/inc/IAnyRefDialog.hxx b/sc/source/ui/inc/IAnyRefDialog.hxx
index afd90f5..eddecd8 100644
--- a/sc/source/ui/inc/IAnyRefDialog.hxx
+++ b/sc/source/ui/inc/IAnyRefDialog.hxx
@@ -53,7 +53,7 @@ public:
     virtual sal_Bool IsDocAllowed( SfxObjectShell* pDocSh ) const = 0;
     virtual void AddRefEntry() = 0;
     virtual void SetActive() = 0;
-    virtual void ViewShellChanged( ScTabViewShell* pScViewShell ) = 0;
+    virtual void ViewShellChanged() = 0;
 };
 
 #endif // SC_IANYREFDIALOG_HXX_INCLUDED
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index b95aa08..cd26719 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -98,7 +98,7 @@ public:
     bool                DoClose( sal_uInt16 nId );
     void                SetDispatcherLock( bool bLock );
     void                EnableSpreadsheets( bool bFlag = true, bool bChildren = true );
-    void                ViewShellChanged( ScTabViewShell* pScViewShell );
+    void                ViewShellChanged();
 
     static              void enableInput(bool _bInput);
 
@@ -112,7 +112,7 @@ public:
 
 //============================================================================
 
-class SC_DLLPUBLIC ScRefHandler : //public SfxModelessDialog,
+class SC_DLLPUBLIC ScRefHandler :
                     public IAnyRefDialog
 {
     Window &    m_rWindow;
@@ -141,9 +141,6 @@ protected:
 
     void                SetDispatcherLock( bool bLock );
 
-    //Overwrite TWindow will implemented by ScRefHdlrImplBase
-    //virtual long        PreNotify( NotifyEvent& rNEvt );
-
     virtual void        RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     virtual void        RefInputDone( sal_Bool bForced = false );
     void                ShowSimpleReference( const XubString& rStr );
@@ -155,8 +152,7 @@ protected:
     void stateChanged(const StateChangedType nStateChange, const bool bBindRef);
 
 public:
-                        ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
-                                     Window* pParent, sal_uInt16 nResId*/, bool bBindRef );
+                        ScRefHandler( Window &rWindow, SfxBindings* pB, bool bBindRef );
     virtual             ~ScRefHandler();
 
     virtual void        SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
@@ -172,14 +168,10 @@ public:
     virtual void        ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
     virtual void        ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
 
-    virtual void        ViewShellChanged( ScTabViewShell* pScViewShell );
+    virtual void        ViewShellChanged();
     void                SwitchToDocument();
-    //SfxBindings&        GetBindings();
 
     virtual void        SetActive() = 0;
-//  virtual sal_Bool        Close();
-    //Overwrite TWindow will implemented by ScRefHdlrImplBase
-    //virtual void        StateChanged( StateChangedType nStateChange );
 
 public:
     bool                EnterRefMode();
@@ -207,7 +199,6 @@ template<  class TWindow, bool bBindRef = true >
 class ScRefHdlrImplBase: public TWindow, public ScRefHandler
 {
 public:
-    //Overwrite TWindow
     virtual long        PreNotify( NotifyEvent& rNEvt );
     virtual void        StateChanged( StateChangedType nStateChange );
 
@@ -231,7 +222,7 @@ ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWi
 
 template<class TWindow, bool bBindRef >
 template<class TParentWindow, class TResId, class TArg>
-ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB /*= NULL*/ )
+ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB )
 :TWindow( pParent, ScResId(static_cast<sal_uInt16>( nResIdP )), rArg ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
 
 template<class TWindow, bool bBindRef >
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 9595cf3..9dd9fb9 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -105,8 +105,8 @@ void ScFormulaReferenceHelper::enableInput( bool bEnable )
                         Window *pParent=pWin->GetParent();
                         if(pParent)
                         {
-                            pParent->EnableInput(bEnable,true /* sal_False */);
-                            if(true /*bChildren*/)
+                            pParent->EnableInput(bEnable,true);
+                            if(true)
                                 pViewSh->EnableRefInput(bEnable);
                         }
                     }
@@ -181,7 +181,7 @@ bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const Strin
 // -----------------------------------------------------------------------------
 void ScFormulaReferenceHelper::ShowFormulaReference( const XubString& rStr )
 {
-    if( /*!pRefEdit &&*/ bEnableColorRef)
+    if( bEnableColorRef)
     {
         bHighLightRef=true;
         ScViewData* pViewData=ScDocShell::GetViewData();
@@ -244,7 +244,7 @@ void ScFormulaReferenceHelper::HideReference( bool bDoneRefMode )
 {
     ScViewData* pViewData=ScDocShell::GetViewData();
 
-    if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef)
+    if( pViewData && bHighLightRef && bEnableColorRef)
     {
         ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
 
@@ -263,7 +263,7 @@ void ScFormulaReferenceHelper::HideReference( bool bDoneRefMode )
 // -----------------------------------------------------------------------------
 void ScFormulaReferenceHelper::ShowReference( const XubString& rStr )
 {
-    if( /*!pRefEdit &&*/ bEnableColorRef )
+    if( bEnableColorRef )
     {
         if( rStr.Search('(')!=STRING_NOTFOUND ||
             rStr.Search('+')!=STRING_NOTFOUND ||
@@ -574,7 +574,7 @@ void ScFormulaReferenceHelper::SetDispatcherLock( bool bLock )
     //  for that view (ScTabViewShell::CreateRefDialog)
 }
 // -----------------------------------------------------------------------------
-void ScFormulaReferenceHelper::ViewShellChanged(ScTabViewShell* /* pScViewShell */)
+void ScFormulaReferenceHelper::ViewShellChanged()
 {
     enableInput( false );
 
@@ -669,16 +669,14 @@ static void lcl_HideAllReferences()
 //  class ScRefHandler
 //----------------------------------------------------------------------------
 
-ScRefHandler::ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
-                          Window* pParent, sal_uInt16 nResId*/, bool bBindRef )
-    :   //SfxModelessDialog ( pB, pCW, pParent, ScResId( nResId ) ),
+ScRefHandler::ScRefHandler( Window &rWindow, SfxBindings* pB, bool bBindRef ):
         m_rWindow( rWindow ),
         m_bInRefMode( false ),
         m_aHelper(this,pB),
         pMyBindings( pB ),
         pActiveWin(NULL)
 {
-    m_aHelper.SetWindow(/*this*/&m_rWindow);
+    m_aHelper.SetWindow(&m_rWindow);
     if(m_rWindow.GetHelpId().isEmpty())                //Hack, da im SfxModelessDialog die HelpId
         m_rWindow.SetHelpId(m_rWindow.GetUniqueId());   //fuer einen ModelessDialog entfernt und
                                     //in eine UniqueId gewandelt wird, machen
@@ -833,7 +831,7 @@ void ScRefHandler::SetDispatcherLock( bool bLock )
 
 void ScRefHandler::ViewShellChanged()
 {
-    m_aHelper.ViewShellChanged(pScViewShell);
+    m_aHelper.ViewShellChanged();
 }
 
 //----------------------------------------------------------------------------
commit c65e7ce3897fd9f9524e23039d39fad6d52fca28
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Dec 3 00:46:02 2012 +0100

    remove debug output
    
    Change-Id: I48b549ab93dc3b937e00f6f35185a6c1c4327bcc

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 0e05389..3e3319c 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1727,7 +1727,6 @@ bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
 
 void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
 {
-    std::cout << "MouseButtonDown" << std::endl;
     nNestedButtonState = SC_NESTEDBUTTON_DOWN;
 
     HandleMouseButtonDown( rMEvt );
@@ -2043,7 +2042,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
 
 void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
 {
-    std::cout << "MouseButtonUp" << std::endl;
     aCurMousePos = rMEvt.GetPosPixel();
     ScDocument* pDoc = pViewData->GetDocument();
     ScMarkData& rMark = pViewData->GetMarkData();
@@ -2472,14 +2470,8 @@ void ScGridWindow::FakeButtonUp()
     }
 }
 
-#include <stdio.h>
-
 void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
 {
-    fprintf( stderr, "MouseMove: %s %d %d %d\n",
-            rMEvt.IsSynthetic() ? "synthetic" : "real",
-            rMEvt.GetMode(), rMEvt.GetModifier(), rMEvt.GetButtons() );
-
     aCurMousePos = rMEvt.GetPosPixel();
 
     if ( rMEvt.IsLeaveWindow() && pNoteMarker && !pNoteMarker->IsByKeyboard() )
commit 204e3eb3813524bf21aae58a76f54f29b969e9ed
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Dec 3 00:43:04 2012 +0100

    ugly hack to avoid virtual method in Window
    
    Change-Id: I7ffc13167f5ecbfe3afab6451e1ef52e81130d48

diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index d8d350c..5c97ed3 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -2325,11 +2325,40 @@ ScAnyRefModalDlg* ScModule::GetCurrentAnyRefDlg()
 void ScModule::PushNewAnyRefDlg( ScAnyRefModalDlg* pNewDlg )
 {
     maAnyRefDlgStack.push( pNewDlg );
+
+    SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+    while(pViewShell)
+    {
+        if ( pViewShell->ISA(ScTabViewShell) )
+        {
+            ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
+            pViewSh->SetInRefMode( true );
+        }
+        pViewShell = SfxViewShell::GetNext( *pViewShell );
+    }
 }
 
 void ScModule::PopAnyRefDlg()
 {
     maAnyRefDlgStack.pop();
+
+    if(maAnyRefDlgStack.empty())
+    {
+        // no modal ref dlg any more
+        // disable the flag in ScGridWindow
+
+        SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+        while(pViewShell)
+        {
+            if ( pViewShell->ISA(ScTabViewShell) )
+            {
+                ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
+                pViewSh->SetInRefMode( false );
+            }
+            pViewShell = SfxViewShell::GetNext( *pViewShell );
+        }
+
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 8c5833a..a6c9f7b 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -372,6 +372,8 @@ public:
     void            UpdateDPFromFieldPopupMenu();
     void            UpdateVisibleRange();
 
+    void            SetInRefMode( bool bRefMode );
+
     // #114409#
     void CursorChanged();
     void DrawLayerCreated();
@@ -392,8 +394,6 @@ public:
     void            UpdateShrinkOverlay();
     void            UpdateAllOverlays();
 
-    virtual bool    IsInRefMode() const { return true; }
-
 protected:
     // #114409#
     void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 218c506..ced5ea5 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -527,6 +527,8 @@ public:
     void            SetBrushDocument( ScDocument* pNew, bool bLock );
     void            SetDrawBrushSet( SfxItemSet* pNew, bool bLock );
     void            ResetBrushDocument();
+
+    void            SetInRefMode( bool bRefMode );
 };
 
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 58fa2f8..0e05389 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5989,4 +5989,15 @@ void ScGridWindow::flushOverlayManager()
         xOverlayManager->flush();
 }
 
+void ScGridWindow::SetInRefMode( bool bInRefMode )
+{
+    WinBits nBits = GetStyle();
+    if(bInRefMode)
+        nBits |= WB_REFMODE;
+    else
+        nBits &= ~WB_REFMODE;
+
+    SetStyle( nBits );
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index 6752ad2..487f5c8 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2325,5 +2325,16 @@ void ScTabView::EnableRefInput(bool bFlag)
         pRowBar[SC_SPLIT_TOP]->EnableInput(bFlag,false);
 }
 
+void ScTabView::SetInRefMode( bool bRefMode )
+{
+    if(pGridWin[SC_SPLIT_BOTTOMLEFT])
+        pGridWin[SC_SPLIT_BOTTOMLEFT]->SetInRefMode( bRefMode );
+    if(pGridWin[SC_SPLIT_BOTTOMRIGHT])
+        pGridWin[SC_SPLIT_BOTTOMRIGHT]->SetInRefMode( bRefMode );
+    if(pGridWin[SC_SPLIT_TOPLEFT])
+        pGridWin[SC_SPLIT_TOPLEFT]->SetInRefMode( bRefMode );
+    if(pGridWin[SC_SPLIT_TOPRIGHT])
+        pGridWin[SC_SPLIT_TOPRIGHT]->SetInRefMode( bRefMode );
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx
index 60f9236..acd1162 100644
--- a/tools/inc/tools/wintypes.hxx
+++ b/tools/inc/tools/wintypes.hxx
@@ -172,6 +172,7 @@ typedef sal_Int64 WinBits;
 #define WB_AUTOVSCROLL          ((WinBits)SAL_CONST_INT64(0x40000000))
 #define WB_HYPHENATION          (((WinBits)SAL_CONST_INT64(0x800000000)) | WB_WORDBREAK)
 #define WB_CHILDDLGCTRL         ((WinBits)SAL_CONST_INT64(0x100000000000))
+#define WB_REFMODE              ((WinBits)SAL_CONST_INT64(0x200000000000))
 
 // system floating window
 #define WB_SYSTEMFLOATWIN       ((WinBits)SAL_CONST_INT64(0x100000000))
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 9ba556c..6eabe15 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -811,7 +811,10 @@ public:
     */
     sal_Bool                IsInModalMode() const;
 
-    virtual bool        IsInRefMode() const;
+    /**
+     *  Necessary for calc ref input handling from modal dialogs
+     */
+    bool                IsInModalNonRefMode() const;
 
     void                SetActivateMode( sal_uInt16 nMode );
     sal_uInt16              GetActivateMode() const;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index d1ea694..fd96248 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3974,7 +3974,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
     }
 
     // If the Window is disabled, then we don't change the focus
-    if ( !IsEnabled() || !IsInputEnabled() /*|| IsInModalMode()*/ )
+    if ( !IsEnabled() || !IsInputEnabled() || IsInModalNonRefMode() )
         return;
 
     // we only need to set the focus if it is not already set
@@ -9275,9 +9275,12 @@ sal_Bool Window::IsInModalMode() const
     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
 }
 
-bool Window::IsInRefMode() const
+bool Window::IsInModalNonRefMode() const
 {
-    return false;
+    if(mpWindowImpl->mnStyle & WB_REFMODE)
+        return false;
+
+    return IsInModalMode();
 }
 
 void Window::ImplIncModalCount()
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index b3494a1..56fc9b1 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -238,7 +238,7 @@ static void ImplHandleMouseHelpRequest( Window* pChild, const Point& rMousePos )
             nHelpMode |= HELPMODE_BALLOON;
         if ( nHelpMode )
         {
-            if ( pChild->IsInputEnabled() /*&& ! pChild->IsInModalMode() */)
+            if ( pChild->IsInputEnabled() && !pChild->IsInModalNonRefMode() )
             {
                 HelpEvent aHelpEvent( rMousePos, nHelpMode );
                 pSVData->maHelpData.mbRequestingHelp = sal_True;
@@ -449,7 +449,7 @@ long ImplHandleMouseEvent( Window* pWindow, sal_uInt16 nSVEvent, sal_Bool bMouse
 
         // no mouse messages to disabled windows
         // #106845# if the window was disabed during capturing we have to pass the mouse events to release capturing
-        if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() /*|| (pChild->IsInModalMode() && !pChild->IsInRefMode())*/ ) )
+        if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalNonRefMode() ) )
         {
             ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave );
             if ( nSVEvent == EVENT_MOUSEMOVE )
commit 06842a8583d3d77de74964cdce4fba811818bf90
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Dec 2 20:33:12 2012 +0100

    first working version of modal ref input dlgs
    
    The following things still need to be changed:
    * don't use virtual method in Window
        * Use a WinBits flag for it
    * move all the dialogs to it
    * fix the ugly hack for range name dlg
    * fix all the uncommented code in winproc.cxx
    * general clean-up
    
    Change-Id: I2a8cfc1c4abf591878b11aa4829a9ff910540eff

diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 521d821..2e7584a 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -41,6 +41,7 @@
 #include <map>
 #include <list>
 #include <algorithm>
+#include <stack>
 
 
 class KeyEvent;
@@ -81,6 +82,7 @@ class ScFormEditData;
 class ScMarkData;
 struct ScDragData;
 struct ScClipData;
+class ScAnyRefModalDlg;
 
 //==================================================================
 
@@ -124,6 +126,7 @@ class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
     bool                mbIsInSharedDocSaving:1;
 
     std::map<sal_uInt16, std::list<Window*> > m_mapRefWindow;
+    std::stack<ScAnyRefModalDlg*> maAnyRefDlgStack;
 public:
                     SFX_DECL_INTERFACE(SCID_APP)
 
@@ -262,6 +265,10 @@ SC_DLLPUBLIC    void                    SetAppOptions   ( const ScAppOptions& rO
     SC_DLLPUBLIC sal_Bool   UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd );
     SC_DLLPUBLIC sal_Bool   IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd );
     SC_DLLPUBLIC Window * Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor );
+
+    ScAnyRefModalDlg* GetCurrentAnyRefDlg();
+    void PushNewAnyRefDlg( ScAnyRefModalDlg* pDlg );
+    void PopAnyRefDlg();
 };
 
 #define SC_MOD() ( *(ScModule**) GetAppData(SHL_CALC) )
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 9c06371..44b0e30 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -260,9 +260,6 @@ void ScDLL::Init()
     ScXMLSourceDlgWrapper       ::RegisterChildWindow(false, pMod);
     ScNameDlgWrapper            ::RegisterChildWindow(false, pMod);
     ScNameDefDlgWrapper         ::RegisterChildWindow(false, pMod);
-    ScCondFormatConditionDlgWrapper ::RegisterChildWindow(false, pMod);
-    ScCondFormatColorScaleDlgWrapper ::RegisterChildWindow(false, pMod);
-    ScCondFormatDataBarDlgWrapper ::RegisterChildWindow(false, pMod);
     ScPivotLayoutWrapper        ::RegisterChildWindow(false, pMod);
     ScTabOpDlgWrapper           ::RegisterChildWindow(false, pMod);
     ScFilterDlgWrapper          ::RegisterChildWindow(false, pMod);
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 2dd1158..d8d350c 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -42,6 +42,7 @@
 #include <sfx2/objface.hxx>
 
 #include "IAnyRefDialog.hxx"
+#include "anyrefdg.hxx"
 
 #include <svtools/ehdl.hxx>
 #include <svtools/accessibilityoptions.hxx>
@@ -1656,12 +1657,17 @@ sal_Bool ScModule::IsModalMode(SfxObjectShell* pDocSh)
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
         if ( pChildWnd )
         {
             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
             bIsModal = pChildWnd->IsVisible() &&
                 !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) );
         }
+        else if(pModalDlg)
+        {
+            bIsModal = pModalDlg->IsVisible() && !(pModalDlg->IsRefInputMode() && pModalDlg->IsDocAllowed(pDocSh) );
+        }
         else
         {
             // in 592 and above, the dialog isn't visible in other views
@@ -1695,8 +1701,11 @@ sal_Bool ScModule::IsTableLocked()
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
         if ( pChildWnd )
             bLocked = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow())->IsTableLocked();
+        else if( pModalDlg )
+            bLocked = pModalDlg->IsTableLocked();
         else
             bLocked = sal_True;     // for other views, see IsModalMode
     }
@@ -1714,8 +1723,11 @@ sal_Bool ScModule::IsRefDialogOpen()
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
         if ( pChildWnd )
             bIsOpen = pChildWnd->IsVisible();
+        else if(pModalDlg)
+            bIsOpen = pModalDlg->IsVisible();
         else
             bIsOpen = sal_True;     // for other views, see IsModalMode
     }
@@ -1733,11 +1745,18 @@ sal_Bool ScModule::IsFormulaMode()
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
         if ( pChildWnd )
         {
             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
             bIsFormula = pChildWnd->IsVisible() && pRefDlg->IsRefInputMode();
         }
+        else if(pModalDlg)
+        {
+            bIsFormula = pModalDlg->IsVisible() && pModalDlg->IsRefInputMode();
+        }
+        else
+            bIsFormula = true;
     }
     else
     {
@@ -1776,7 +1795,8 @@ void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
     if( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
-        OSL_ENSURE( pChildWnd, "NoChildWin" );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
+        OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
         if ( pChildWnd )
         {
             if ( nCurRefDlgId == SID_OPENDLG_CONSOLIDATE && pMarkData )
@@ -1795,6 +1815,13 @@ void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
             pRefDlg->HideReference( false );
             pRefDlg->SetReference( aNew, pDoc );
         }
+        else if(pModalDlg)
+        {
+            //  hide the (color) selection now instead of later from LoseFocus,
+            //  don't abort the ref input that causes this call (bDoneRefMode = sal_False)
+            pModalDlg->HideReference( false );
+            pModalDlg->SetReference( aNew, pDoc );
+        }
     }
     else
     {
@@ -1816,12 +1843,15 @@ void ScModule::AddRefEntry()                        // "Mehrfachselektion"
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
-        OSL_ENSURE( pChildWnd, "NoChildWin" );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
+        OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
         if ( pChildWnd )
         {
             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
             pRefDlg->AddRefEntry();
         }
+        else if(pModalDlg)
+            pModalDlg->AddRefEntry();
     }
     else
     {
@@ -1843,12 +1873,15 @@ void ScModule::EndReference()
     if ( nCurRefDlgId )
     {
         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
-        OSL_ENSURE( pChildWnd, "NoChildWin" );
+        ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
+        OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
         if ( pChildWnd )
         {
             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
             pRefDlg->SetActive();
         }
+        else
+            pModalDlg->SetActive();
     }
 }
 
@@ -2281,4 +2314,22 @@ Window *  ScModule::Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor )
     return NULL;
 }
 
+ScAnyRefModalDlg* ScModule::GetCurrentAnyRefDlg()
+{
+    if(!maAnyRefDlgStack.empty())
+        return maAnyRefDlgStack.top();
+
+    return NULL;
+}
+
+void ScModule::PushNewAnyRefDlg( ScAnyRefModalDlg* pNewDlg )
+{
+    maAnyRefDlgStack.push( pNewDlg );
+}
+
+void ScModule::PopAnyRefDlg()
+{
+    maAnyRefDlgStack.pop();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 8780647..78214aa 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -355,9 +355,9 @@ IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
 //ScCondFormatDlg
 //---------------------------------------------------
 
-ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange,
+ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange,
                                     const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType):
-    ScAnyRefDlg(pB, pCW, pParent, RID_SCDLG_CONDFORMAT ),
+    ScAnyRefModalDlg(pParent, ScResId(RID_SCDLG_CONDFORMAT) ),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
     maBtnRemove( this, ScResId( BTN_REMOVE ) ),
     maBtnOk( this, ScResId( BTN_OK ) ),
@@ -388,10 +388,13 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW, Window* p
     FreeResource();
 
     maEdRange.SetText(aRangeString);
+
+    SC_MOD()->PushNewAnyRefDlg(this);
 }
 
 ScCondFormatDlg::~ScCondFormatDlg()
 {
+    SC_MOD()->PopAnyRefDlg();
 }
 
 void ScCondFormatDlg::SetActive()
@@ -406,7 +409,7 @@ void ScCondFormatDlg::SetActive()
 
 void ScCondFormatDlg::RefInputDone( sal_Bool bForced )
 {
-    ScAnyRefDlg::RefInputDone(bForced);
+    ScAnyRefModalDlg::RefInputDone(bForced);
 }
 
 sal_Bool ScCondFormatDlg::IsTableLocked() const
@@ -483,21 +486,8 @@ IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit*, pEdit )
 
 sal_Bool ScCondFormatDlg::Close()
 {
-    sal_uInt16 nId = 0;
-    switch(meType)
-    {
-        case condformat::dialog::NONE:
-        case condformat::dialog::CONDITION:
-            nId = ScCondFormatConditionDlgWrapper::GetChildWindowId();
-            break;
-        case condformat::dialog::COLORSCALE:
-            nId = ScCondFormatColorScaleDlgWrapper::GetChildWindowId();
-            break;
-        case condformat::dialog::DATABAR:
-            nId = ScCondFormatDataBarDlgWrapper::GetChildWindowId();
-            break;
-    }
-
+    sal_uInt16 nId = 1;
+    EndDialog();
     return DoClose(nId);
 }
 
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 8039738..b8fb972 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -193,6 +193,11 @@ ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
     delete mpFormatList;
 }
 
+bool ScCondFormatManagerDlg::IsInRefMode() const
+{
+    return true;
+}
+
 ScConditionalFormatList* ScCondFormatManagerDlg::GetConditionalFormatList()
 {
     ScConditionalFormatList* pList = mpFormatList;
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
index 4c01577..b8682d0 100644
--- a/sc/source/ui/formdlg/formula.cxx
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -526,9 +526,9 @@ void ScFormulaDlg::HideReference( sal_Bool bDoneRefMode )
 {
     m_aHelper.HideReference(bDoneRefMode);
 }
-void ScFormulaDlg::ViewShellChanged( ScTabViewShell* pScViewShell )
+void ScFormulaDlg::ViewShellChanged()
 {
-    m_aHelper.ViewShellChanged( pScViewShell );
+    m_aHelper.ViewShellChanged();
 }
 void ScFormulaDlg::AddRefEntry( )
 {
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
index 8b66f68..b95aa08 100644
--- a/sc/source/ui/inc/anyrefdg.hxx
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -190,8 +190,21 @@ public:
 
 //============================================================================
 
+
+class ScRefHdlModalImpl : public ModalDialog, public ScRefHandler
+{
+public:
+
+    virtual long        PreNotify( NotifyEvent& rNEvt );
+    virtual void        StateChanged( StateChangedType nStateChange );
+protected:
+    ScRefHdlModalImpl( Window* pParent, ResId& rResId );
+
+private:
+};
+
 template<  class TWindow, bool bBindRef = true >
-class ScRefHdlrImplBase:public TWindow, public ScRefHandler
+class ScRefHdlrImplBase: public TWindow, public ScRefHandler
 {
 public:
     //Overwrite TWindow
@@ -238,14 +251,20 @@ void ScRefHdlrImplBase<TWindow, bBindRef>::StateChanged( StateChangedType nState
     ScRefHandler::stateChanged( nStateChange, bBindRef );
 }
 
+class ScAnyRefModalDlg : public ScRefHdlModalImpl
+{
+public:
+    ScAnyRefModalDlg(Window* pParent, ResId rResId);
+};
+
 //============================================================================
 template<class TDerived, class TBase, bool bBindRef = true>
-struct ScRefHdlrImpl: ScRefHdlrImplBase<TBase, bBindRef >
+struct ScRefHdlrImpl: ScRefHdlrImplBase< TBase, bBindRef >
 {
     enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
 
     template<class T1, class T2, class T3, class T4>
-    ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4 )
+    ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ):ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4 )
     {
         SC_MOD()->RegisterRefWindow( static_cast<sal_uInt16>( static_cast<TDerived*>(this)->SLOTID ), this );
     }
@@ -259,7 +278,7 @@ struct ScRefHdlrImpl: ScRefHdlrImplBase<TBase, bBindRef >
 struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
 {
     template<class T1, class T2, class T3, class T4>
-    ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4){}
+    ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3& rt3, const T4& rt4 ):ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4){}
 };
 //============================================================================
 
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 194d60c..f5c3e25 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -96,7 +96,7 @@ public:
     DECL_LINK( ColFormatTypeHdl, ListBox*);
 };
 
-class ScCondFormatDlg : public ScAnyRefDlg
+class ScCondFormatDlg : public ScAnyRefModalDlg
 {
 private:
     PushButton maBtnAdd;
@@ -129,7 +129,7 @@ protected:
 
 
 public:
-    ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pSW, Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+    ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat,
             const ScRangeList& rRange, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType);
     virtual ~ScCondFormatDlg();
 
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
index cb41d20..c13ff6b 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -87,6 +87,8 @@ public:
 
     bool CondFormatsChanged();
 
+    virtual bool IsInRefMode() const;
+
 private:
     PushButton maBtnAdd;
     PushButton maBtnRemove;
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
index 8fcc104..04c2ba5 100644
--- a/sc/source/ui/inc/formula.hxx
+++ b/sc/source/ui/inc/formula.hxx
@@ -110,7 +110,7 @@ public:
     virtual sal_Bool IsDocAllowed( SfxObjectShell* pDocSh ) const;
     virtual void AddRefEntry();
     virtual void SetActive();
-    virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
+    virtual void ViewShellChanged();
 protected:
 
     virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index fdd7b2e..8c5833a 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -392,6 +392,8 @@ public:
     void            UpdateShrinkOverlay();
     void            UpdateAllOverlays();
 
+    virtual bool    IsInRefMode() const { return true; }
+
 protected:
     // #114409#
     void ImpCreateOverlayObjects();
diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx
index 447383b..19a08c5 100644
--- a/sc/source/ui/inc/reffact.hxx
+++ b/sc/source/ui/inc/reffact.hxx
@@ -45,9 +45,6 @@
 
 DECL_WRAPPER_WITHID(ScNameDlgWrapper)
 DECL_WRAPPER_WITHID(ScNameDefDlgWrapper)
-DECL_WRAPPER_WITHID(ScCondFormatConditionDlgWrapper)
-DECL_WRAPPER_WITHID(ScCondFormatColorScaleDlgWrapper)
-DECL_WRAPPER_WITHID(ScCondFormatDataBarDlgWrapper)
 DECL_WRAPPER_WITHID(ScSolverDlgWrapper)
 DECL_WRAPPER_WITHID(ScOptSolverDlgWrapper)
 DECL_WRAPPER_WITHID(ScXMLSourceDlgWrapper)
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 3b4e9a4..9595cf3 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -831,7 +831,7 @@ void ScRefHandler::SetDispatcherLock( bool bLock )
 
 //----------------------------------------------------------------------------
 
-void ScRefHandler::ViewShellChanged(ScTabViewShell*  pScViewShell )
+void ScRefHandler::ViewShellChanged()
 {
     m_aHelper.ViewShellChanged(pScViewShell);
 }
@@ -937,4 +937,25 @@ void ScRefHandler::RefInputDone( sal_Bool bForced )
     m_aHelper.RefInputDone( bForced );
 }
 
+//-------------------------------------------------------------------------------
+
+ScRefHdlModalImpl::ScRefHdlModalImpl( Window* pParent, ResId& rResId ):
+    ModalDialog( pParent, rResId ),
+    ScRefHandler(dynamic_cast<Window&>(*this), NULL, true) {}
+
+long ScRefHdlModalImpl::PreNotify( NotifyEvent& rNEvt )
+{
+    ScRefHandler::preNotify( rNEvt, true );
+    return ModalDialog::PreNotify( rNEvt );
+}
+
+void ScRefHdlModalImpl::StateChanged( StateChangedType nStateChange )
+{
+    ModalDialog::StateChanged( nStateChange );
+    ScRefHandler::stateChanged( nStateChange, true );
+}
+
+ScAnyRefModalDlg::ScAnyRefModalDlg( Window* pParent, ResId aResId ):
+    ScRefHdlModalImpl( pParent, aResId ) {}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index e0a5f25..22ca8fe 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -28,7 +28,7 @@
 
 #include "condformatdlg.hrc"
 
-ModelessDialog RID_SCDLG_CONDFORMAT
+ModalDialog RID_SCDLG_CONDFORMAT
 {
     OutputSize = TRUE;
     Hide = TRUE;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 426e803..e8122b3 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -83,6 +83,7 @@
 #include "cliputil.hxx"
 #include "markdata.hxx"
 #include "docpool.hxx"
+#include "condformatdlg.hxx"
 
 #include "globstr.hrc"
 #include "scui_def.hxx"
@@ -1769,25 +1770,58 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
         case SID_OPENDLG_COLORSCALE:
         case SID_OPENDLG_DATABAR:
             {
-                sal_uInt16 nId = 0;
-                switch( nSlot )
+                sal_uInt16 nId = 1;
+
+                pScMod->SetRefDialog( nId, true );
+
+                ScRangeList aRangeList;
+                ScViewData* pData = GetViewData();
+                pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
+
+                ScDocument* pDoc = GetViewData()->GetDocument();
+                if(pDoc->IsTabProtected(pData->GetTabNo()))
                 {
-                    case SID_OPENDLG_CONDFRMT:
-                        nId = ScCondFormatConditionDlgWrapper::GetChildWindowId();
-                        break;
-                    case SID_OPENDLG_COLORSCALE:
-                        nId = ScCondFormatColorScaleDlgWrapper::GetChildWindowId();
-                        break;
-                    case SID_OPENDLG_DATABAR:
-                        nId = ScCondFormatDataBarDlgWrapper::GetChildWindowId();
-                        break;
-                    default:
-                        break;
+                    //ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
+                    break;
+                }
+
+                ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
+                if(aRangeList.empty())
+                {
+                    ScRange* pRange = new ScRange(aPos);
+                    aRangeList.push_back(pRange);
+                }
+
+                const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
+                ScCondFormatDlg* pCondFormatDlg = NULL;
+                if(pCondFormat)
+                {
+                    const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
+                    if(rCondFormatRange == aRangeList)
+                        pCondFormatDlg = new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, rCondFormatRange, aPos, condformat::dialog::NONE );
+                }
+
+                if(!pCondFormatDlg)
+                {
+                    condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE;
+                    switch(nSlot)
+                    {
+                        case SID_OPENDLG_CONDFRMT:
+                            eType = condformat::dialog::CONDITION;
+                            break;
+                        case SID_OPENDLG_COLORSCALE:
+                            eType = condformat::dialog::COLORSCALE;
+                            break;
+                        case SID_OPENDLG_DATABAR:
+                            eType = condformat::dialog::DATABAR;
+                            break;
+                        default:
+                            break;
+                    }
+                    pCondFormatDlg = new ScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), eType );
+                    pCondFormatDlg->Execute();
                 }
-                SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
-                SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
 
-                pScMod->SetRefDialog( nId, pWnd ? false : sal_True );
             }
             break;
 
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 247ff73..58fa2f8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -1727,6 +1727,7 @@ bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, bool bAction )
 
 void ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
 {
+    std::cout << "MouseButtonDown" << std::endl;
     nNestedButtonState = SC_NESTEDBUTTON_DOWN;
 
     HandleMouseButtonDown( rMEvt );
@@ -2042,6 +2043,7 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
 
 void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
 {
+    std::cout << "MouseButtonUp" << std::endl;
     aCurMousePos = rMEvt.GetPosPixel();
     ScDocument* pDoc = pViewData->GetDocument();
     ScMarkData& rMark = pViewData->GetMarkData();
@@ -2470,8 +2472,14 @@ void ScGridWindow::FakeButtonUp()
     }
 }
 
+#include <stdio.h>
+
 void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
 {
+    fprintf( stderr, "MouseMove: %s %d %d %d\n",
+            rMEvt.IsSynthetic() ? "synthetic" : "real",
+            rMEvt.GetMode(), rMEvt.GetModifier(), rMEvt.GetButtons() );
+
     aCurMousePos = rMEvt.GetPosPixel();
 
     if ( rMEvt.IsLeaveWindow() && pNoteMarker && !pNoteMarker->IsByKeyboard() )
@@ -2749,7 +2757,7 @@ void ScGridWindow::Tracking( const TrackingEvent& rTEvt )
 
     if ( rTEvt.IsTrackingCanceled() )       // alles abbrechen...
     {
-        if (!pViewData->GetView()->IsInActivatePart())
+        if (!pViewData->GetView()->IsInActivatePart() && !SC_MOD()->IsRefDialogOpen())
         {
             if (bDPMouse)
                 bDPMouse = false;               // gezeichnet wird per bDragRect
diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
index 052fcaf..a7cebc4 100644
--- a/sc/source/ui/view/reffact.cxx
+++ b/sc/source/ui/view/reffact.cxx
@@ -44,9 +44,6 @@
 
 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDlgWrapper, FID_DEFINE_NAME )
 SFX_IMPL_MODELESSDIALOG_WITHID(ScNameDefDlgWrapper, FID_ADD_NAME )
-SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatConditionDlgWrapper, SID_OPENDLG_CONDFRMT )
-SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatColorScaleDlgWrapper, SID_OPENDLG_COLORSCALE )
-SFX_IMPL_MODELESSDIALOG_WITHID(ScCondFormatDataBarDlgWrapper, SID_OPENDLG_DATABAR )
 SFX_IMPL_MODELESSDIALOG_WITHID(ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
 SFX_IMPL_MODELESSDIALOG_WITHID(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
 SFX_IMPL_MODELESSDIALOG_WITHID(ScXMLSourceDlgWrapper, SID_MANAGE_XML_SOURCE)
@@ -121,24 +118,6 @@ IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME )
 IMPL_CHILD_CTOR( ScNameDefDlgWrapper, FID_ADD_NAME )
 
 //-------------------------------------------------------------------------
-// ScCondFormatConditionDlgWrapper
-//-------------------------------------------------------------------------
-
-IMPL_CHILD_CTOR( ScCondFormatConditionDlgWrapper, SID_OPENDLG_CONDFRMT )
-
-//-------------------------------------------------------------------------
-// ScCondFormatColorScaleDlgWrapper
-//-------------------------------------------------------------------------
-
-IMPL_CHILD_CTOR( ScCondFormatColorScaleDlgWrapper, SID_OPENDLG_COLORSCALE )
-
-//-------------------------------------------------------------------------
-// ScCondFormatDataBarDlgWrapper
-//-------------------------------------------------------------------------
-
-IMPL_CHILD_CTOR( ScCondFormatDataBarDlgWrapper, SID_OPENDLG_DATABAR )
-
-//-------------------------------------------------------------------------
 // ScSolverDlgWrapper
 //-------------------------------------------------------------------------
 
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f31cddc..7b10ecc 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1741,7 +1741,7 @@ void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSa
             if ( pChildWnd )
             {
                 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
-                pRefDlg->ViewShellChanged(NULL);
+                pRefDlg->ViewShellChanged();
             }
         }
     }
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
index 75f3836..893f251 100644
--- a/sc/source/ui/view/tabvwsh.cxx
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -65,9 +65,6 @@ SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
     SFX_CHILDWINDOW_REGISTRATION(SID_TASKPANE);
     SFX_CHILDWINDOW_REGISTRATION(ScNameDlgWrapper::GetChildWindowId());
     SFX_CHILDWINDOW_REGISTRATION(ScNameDefDlgWrapper::GetChildWindowId());
-    SFX_CHILDWINDOW_REGISTRATION(ScCondFormatConditionDlgWrapper::GetChildWindowId());
-    SFX_CHILDWINDOW_REGISTRATION(ScCondFormatColorScaleDlgWrapper::GetChildWindowId());
-    SFX_CHILDWINDOW_REGISTRATION(ScCondFormatDataBarDlgWrapper::GetChildWindowId());
     SFX_CHILDWINDOW_REGISTRATION(ScSolverDlgWrapper::GetChildWindowId());
     SFX_CHILDWINDOW_REGISTRATION(ScOptSolverDlgWrapper::GetChildWindowId());
     SFX_CHILDWINDOW_REGISTRATION(ScXMLSourceDlgWrapper::GetChildWindowId());
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 595a93f..94314f6 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -210,7 +210,7 @@ void ScTabViewShell::Activate(sal_Bool bMDI)
             if ( pChildWnd )
             {
                 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
-                pRefDlg->ViewShellChanged(this);
+                pRefDlg->ViewShellChanged();
             }
         }
     }
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 289e605..d3c57d6 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -182,59 +182,6 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
         }
         break;
 
-        case SID_OPENDLG_CONDFRMT:
-        case SID_OPENDLG_COLORSCALE:
-        case SID_OPENDLG_DATABAR:
-        {
-            ScRangeList aRangeList;
-            ScViewData* pData = GetViewData();
-            pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
-
-            if(pDoc->IsTabProtected(pData->GetTabNo()))
-            {
-                ErrorMessage( STR_ERR_CONDFORMAT_PROTECTED );
-                break;
-            }
-
-            ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
-            if(aRangeList.empty())
-            {
-                ScRange* pRange = new ScRange(aPos);
-                aRangeList.push_back(pRange);
-            }
-
-            const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
-            condformat::dialog::ScCondFormatDialogType eType = condformat::dialog::NONE;
-            switch(nSlotId)
-            {
-                case SID_OPENDLG_CONDFRMT:
-                    eType = condformat::dialog::CONDITION;
-                    break;
-                case SID_OPENDLG_COLORSCALE:
-                    eType = condformat::dialog::COLORSCALE;
-                    break;
-                case SID_OPENDLG_DATABAR:
-                    eType = condformat::dialog::DATABAR;
-                    break;
-                default:
-                    break;
-            }
-
-            if(pCondFormat)
-            {
-                const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
-                if(rCondFormatRange == aRangeList)
-                    pResult = new ScCondFormatDlg( pB, pCW, pParent, pDoc, pCondFormat, rCondFormatRange, aPos, eType );
-            }
-
-            if(!pResult)
-            {
-                pResult = new ScCondFormatDlg( pB, pCW, pParent, pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), eType );
-            }
-        }
-
-        break;
-
         case SID_DEFINE_COLROWNAMERANGES:
         {
             pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 9ef1688..9ba556c 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -811,6 +811,8 @@ public:
     */
     sal_Bool                IsInModalMode() const;
 
+    virtual bool        IsInRefMode() const;
+
     void                SetActivateMode( sal_uInt16 nMode );
     sal_uInt16              GetActivateMode() const;
 
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 7e7538a..d1ea694 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -3974,7 +3974,7 @@ void Window::ImplGrabFocus( sal_uInt16 nFlags )
     }
 
     // If the Window is disabled, then we don't change the focus
-    if ( !IsEnabled() || !IsInputEnabled() || IsInModalMode() )
+    if ( !IsEnabled() || !IsInputEnabled() /*|| IsInModalMode()*/ )
         return;
 
     // we only need to set the focus if it is not already set
@@ -9274,6 +9274,12 @@ sal_Bool Window::IsInModalMode() const
 {
     return (mpWindowImpl->mpFrameWindow->mpWindowImpl->mpFrameData->mnModalMode != 0);
 }
+
+bool Window::IsInRefMode() const
+{
+    return false;
+}
+
 void Window::ImplIncModalCount()
 {
     Window* pFrameWindow = mpWindowImpl->mpFrameWindow;
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 6a12759..b3494a1 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -238,7 +238,7 @@ static void ImplHandleMouseHelpRequest( Window* pChild, const Point& rMousePos )
             nHelpMode |= HELPMODE_BALLOON;
         if ( nHelpMode )
         {
-            if ( pChild->IsInputEnabled() && ! pChild->IsInModalMode() )
+            if ( pChild->IsInputEnabled() /*&& ! pChild->IsInModalMode() */)
             {
                 HelpEvent aHelpEvent( rMousePos, nHelpMode );
                 pSVData->maHelpData.mbRequestingHelp = sal_True;
@@ -449,7 +449,7 @@ long ImplHandleMouseEvent( Window* pWindow, sal_uInt16 nSVEvent, sal_Bool bMouse
 
         // no mouse messages to disabled windows
         // #106845# if the window was disabed during capturing we have to pass the mouse events to release capturing
-        if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() || pChild->IsInModalMode() ) )
+        if ( pSVData->maWinData.mpCaptureWin != pChild && (!pChild->IsEnabled() || !pChild->IsInputEnabled() /*|| (pChild->IsInModalMode() && !pChild->IsInRefMode())*/ ) )
         {
             ImplHandleMouseFloatMode( pChild, aMousePos, nCode, nSVEvent, bMouseLeave );
             if ( nSVEvent == EVENT_MOUSEMOVE )


More information about the Libreoffice-commits mailing list