Tag: cws_dev300_sqlsyntaxhighlighting
User: mod     
Date: 2008-07-19 11:58:51+0000
Modified:
   dba/dbaccess/source/ui/control/sqledit.cxx
   dba/dbaccess/source/ui/inc/sqledit.hxx

Log:
 derive from MultiLineEditSyntaxHighlighter

File Changes:

Directory: /dba/dbaccess/source/ui/control/
===========================================

File [changed]: sqledit.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/control/sqledit.cxx?r1=1.12&r2=1.12.16.1
Delta lines:  +50 -7
--------------------
--- sqledit.cxx 2008-06-25 12:43:54+0000        1.12
+++ sqledit.cxx 2008-07-19 11:58:49+0000        1.12.16.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqledit.cxx,v $
- * $Revision: 1.12 $
+ * $Revision: 1.12.16.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -55,6 +55,8 @@
 #ifndef DBAUI_QUERYDESIGNVIEW_HXX
 #include "QueryDesignView.hxx"
 #endif
+
+#include <svtools/sourceviewconfig.hxx>
 //////////////////////////////////////////////////////////////////////////
 // OSqlEdit
 
//------------------------------------------------------------------------------
@@ -62,10 +64,11 @@
 
 DBG_NAME(OSqlEdit)
 OSqlEdit::OSqlEdit( OQueryTextView* pParent,  WinBits nWinStyle ) :
-       MultiLineEdit( pParent, nWinStyle )
+       MultiLineEditSyntaxHighlight( pParent, nWinStyle )
        ,m_pView(pParent)
        ,m_bAccelAction( sal_False )
        ,m_bStopTimer(sal_False )
+       ,pSourceViewConfig(new svt::SourceViewConfig)
 {
        DBG_CTOR(OSqlEdit,NULL);
        SetHelpId( HID_CTL_QRYSQLEDIT );
@@ -77,6 +80,9 @@
        m_timerInvalidate.SetTimeout(200);
        m_timerInvalidate.SetTimeoutHdl(LINK(this, OSqlEdit, 
OnInvalidateTimer));
        m_timerInvalidate.Start();
+
+       ImplSetFont();
+       StartListening(*pSourceViewConfig);
 }
 
 
//------------------------------------------------------------------------------
@@ -85,6 +91,8 @@
        DBG_DTOR(OSqlEdit,NULL);
        if (m_timerUndoActionCreation.IsActive())
                m_timerUndoActionCreation.Stop();       
+       EndListening(*pSourceViewConfig);
+       delete pSourceViewConfig;
 }
 
//------------------------------------------------------------------------------
 void OSqlEdit::KeyInput( const KeyEvent& rKEvt )
@@ -98,7 +106,10 @@
        if( 
(aKeyFunc==KEYFUNC_CUT)||(aKeyFunc==KEYFUNC_COPY)||(aKeyFunc==KEYFUNC_PASTE) )
                m_bAccelAction = sal_True;
 
-       MultiLineEdit::KeyInput( rKEvt );
+       // TODO: set () and "" to bold
+       // will sytnax highlighting set it correctly afterwards
+
+       MultiLineEditSyntaxHighlight::KeyInput( rKEvt );
 
        if( m_bAccelAction )
                m_bAccelAction = sal_False;
@@ -121,7 +132,7 @@
 {
        DBG_CHKTHIS(OSqlEdit,NULL);
        m_strOrigText  =GetText();
-       MultiLineEdit::GetFocus();
+       MultiLineEditSyntaxHighlight::GetFocus();
 }
 
 
//------------------------------------------------------------------------------
@@ -181,7 +192,7 @@
                LINK(this, OSqlEdit, OnUndoActionTimer).Call(NULL);
        }
 
-       MultiLineEdit::SetText(rNewText);
+       MultiLineEditSyntaxHighlight::SetText(rNewText);
        m_strOrigText  =rNewText;
 }
 // 
-----------------------------------------------------------------------------
@@ -199,4 +210,36 @@
                m_timerInvalidate.Start();
 }
 
+void OSqlEdit::Notify( SfxBroadcaster& rBC, const SfxHint& /*rHint*/ )
+{
+       if (&rBC == pSourceViewConfig )
+       {
+               ImplSetFont();        
+       }
+}
+
+long OSqlEdit::Notify( NotifyEvent& rNEvt )
+{
+       return MultiLineEditSyntaxHighlight::Notify(rNEvt);
+}
+
+void OSqlEdit::ImplSetFont()
+{
+       if (pSourceViewConfig)
+       {
+               AllSettings aSettings = GetSettings();
+               StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+               String sFontName = pSourceViewConfig->GetFontName();
+               if ( !sFontName.Len() )
+               {
+                       Font aTmpFont( OutputDevice::GetDefaultFont( 
DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
+                       sFontName = aTmpFont.GetName();
+               }
+               Size aFontSize( 0, pSourceViewConfig->GetFontHeight() );
+               Font aFont( sFontName, aFontSize );
+               aStyleSettings.SetFieldFont(aFont);
+               aSettings.SetStyleSettings(aStyleSettings);
+               SetSettings(aSettings);
+       }
+}
 
//==============================================================================

Directory: /dba/dbaccess/source/ui/inc/
=======================================

File [changed]: sqledit.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/sqledit.hxx?r1=1.5&r2=1.5.60.1
Delta lines:  +14 -6
--------------------
--- sqledit.hxx 2008-04-10 15:47:18+0000        1.5
+++ sqledit.hxx 2008-07-19 11:58:49+0000        1.5.60.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqledit.hxx,v $
- * $Revision: 1.5 $
+ * $Revision: 1.5.60.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -30,14 +30,15 @@
 #ifndef DBAUI_SQLEDIT_HXX
 #define DBAUI_SQLEDIT_HXX
 
-#ifndef _SVEDIT_HXX 
 #include <svtools/svmedit.hxx>
-#endif
+#include <svtools/lstner.hxx>
+
+namespace svt{ class SourceViewConfig;}
 
 namespace dbaui
 {
        class OQueryTextView;
-       class OSqlEdit : public MultiLineEdit
+       class OSqlEdit : public MultiLineEditSyntaxHighlight, SfxListener
        {
        private:
                Timer   m_timerInvalidate;
@@ -47,10 +48,14 @@
                OQueryTextView* m_pView;
                BOOL    m_bAccelAction;         // Wird bei Cut, Copy, Paste 
gesetzt
                BOOL    m_bStopTimer;
+               svt::SourceViewConfig*  pSourceViewConfig;
 
                DECL_LINK(OnUndoActionTimer, void*);
                DECL_LINK(OnInvalidateTimer, void*);
 
+       private: 
+               void                    ImplSetFont();
+
        protected:
                virtual void KeyInput( const KeyEvent& rKEvt );
                virtual void GetFocus();
@@ -63,7 +68,7 @@
 
         // Edit overridables
                virtual void SetText(const String& rNewText);
-        using MultiLineEdit::SetText;
+        using MultiLineEditSyntaxHighlight::SetText;
 
         // own functionality
                BOOL IsInAccelAct();
@@ -75,6 +80,9 @@
 
                void stopTimer();
                void startTimer();
+
+               virtual void    Notify( SfxBroadcaster& rBC, const SfxHint& 
rHint );
+               virtual long    Notify( NotifyEvent& rNEvt );
        };
 }
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to