summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-01-25 18:18:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-01-25 18:18:52 +0100
commita2195b2dc301a6c2cfd0bf1a7ff74483bcc5998a (patch)
treeed7d466e0c75fcc7bf9ca0a0dfa9b8b23ef0a89a /basctl
parentd70aa23c2d3af951c8846b4aea83c87c06a37a35 (diff)
Replace SourceViewConfig with (simplified) direct configuration access.
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.hxx24
-rw-r--r--basctl/source/basicide/baside2b.cxx108
2 files changed, 87 insertions, 45 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8d5aab9d5f29..a44e02b8e796 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -50,6 +50,7 @@ class SvxSearchItem;
#include <sfx2/progress.hxx>
#include <svtools/syntaxhighlight.hxx>
+#include <unotools/options.hxx>
#include "breakpoint.hxx"
#include "linenumberwindow.hxx"
@@ -58,10 +59,9 @@ DBG_NAMEEX( ModulWindow )
#define MARKER_NOMARKER 0xFFFF
-namespace utl
-{
- class SourceViewConfig;
-}
+namespace com { namespace sun { namespace star { namespace beans {
+ class XMultiPropertySet;
+} } } }
// #108672 Helper functions to get/set text in TextEngine
// using the stream interface (get/setText() only supports
@@ -91,18 +91,19 @@ inline void ProgressInfo::StepProgress()
SetState( ++nCurState );
}
-
-namespace svt {
-class SourceViewConfig;
-}
-
-class EditorWindow : public Window, public SfxListener, public utl::ConfigurationListener
+class EditorWindow : public Window, public SfxListener
{
private:
+ class ChangesListener;
+ friend class ChangesListener;
+
ExtTextView* pEditView;
ExtTextEngine* pEditEngine;
- utl::SourceViewConfig* pSourceViewConfig;
+ rtl::Reference< ChangesListener > listener_;
+ osl::Mutex mutex_;
+ com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet >
+ notifier_;
long nCurTextWidth;
@@ -139,7 +140,6 @@ protected:
virtual void Command( const CommandEvent& rCEvt );
virtual void LoseFocus();
virtual void RequestHelp( const HelpEvent& rHEvt );
- virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
void DoSyntaxHighlight( sal_uLong nPara );
String GetWordAtCursor();
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 52f9752fbe17..101fcfd88825 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -40,8 +40,11 @@
#include <basic/sbmeth.hxx>
#include <basic/sbuno.hxx>
#include <com/sun/star/script/XLibraryContainer2.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
+#include <officecfg/Office/Common.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <vcl/msgbox.hxx>
@@ -52,7 +55,6 @@
#include <svtools/textwindowpeer.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/help.hxx>
-#include <unotools/sourceviewconfig.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -147,6 +149,30 @@ void lcl_SeparateNameAndIndex( const String& rVName, String& rVar, String& rInde
}
}
+class EditorWindow::ChangesListener:
+ public cppu::WeakImplHelper1< beans::XPropertiesChangeListener >
+{
+public:
+ ChangesListener(EditorWindow & editor): editor_(editor) {}
+
+private:
+ virtual ~ChangesListener() {}
+
+ virtual void disposing(lang::EventObject const &) throw (RuntimeException)
+ {
+ osl::MutexGuard g(editor_.mutex_);
+ editor_.notifier_.clear();
+ }
+
+ virtual void propertiesChange(
+ Sequence< beans::PropertyChangeEvent > const &) throw (RuntimeException)
+ {
+ SolarMutexGuard g;
+ editor_.ImplSetFont();
+ }
+
+ EditorWindow & editor_;
+};
EditorWindow::EditorWindow( Window* pParent ) :
Window( pParent, WB_BORDER )
@@ -156,7 +182,6 @@ EditorWindow::EditorWindow( Window* pParent ) :
pModulWindow = 0;
pEditView = 0;
pEditEngine = 0;
- pSourceViewConfig = new utl::SourceViewConfig;
bHighlightning = sal_False;
pProgress = 0;
nCurTextWidth = 0;
@@ -165,15 +190,35 @@ EditorWindow::EditorWindow( Window* pParent ) :
SetPointer( Pointer( POINTER_TEXT ) );
SetHelpId( HID_BASICIDE_EDITORWINDOW );
- pSourceViewConfig->AddListener(this);
+
+ // Using "this" in ctor is a little fishy, but should work here at least as
+ // long as there are no derivations:
+ listener_ = new ChangesListener(*this);
+ Reference< beans::XMultiPropertySet > n(
+ officecfg::Office::Common::Font::SourceViewFont::get(
+ comphelper::getProcessComponentContext()), UNO_QUERY_THROW);
+ {
+ osl::MutexGuard g(mutex_);
+ notifier_ = n;
+ }
+ Sequence< rtl::OUString > s(2);
+ s[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontHeight"));
+ s[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontName"));
+ n->addPropertiesChangeListener(s, listener_.get());
}
EditorWindow::~EditorWindow()
{
- pSourceViewConfig->RemoveListener(this);
- delete pSourceViewConfig;
+ Reference< beans::XMultiPropertySet > n;
+ {
+ osl::MutexGuard g(mutex_);
+ n = notifier_;
+ }
+ if (n.is()) {
+ n->removePropertiesChangeListener(listener_.get());
+ }
aSyntaxIdleTimer.Stop();
@@ -704,11 +749,6 @@ void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
-void EditorWindow::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
-{
- ImplSetFont();
-}
-
void EditorWindow::SetScrollBarRanges()
{
// extra method, not InitScrollBars, because for EditEngine events too
@@ -775,32 +815,34 @@ void EditorWindow::ImpDoHighlight( sal_uLong nLine )
void EditorWindow::ImplSetFont()
{
- if ( pSourceViewConfig )
+ rtl::OUString sFontName(
+ officecfg::Office::Common::Font::SourceViewFont::FontName::get(
+ comphelper::getProcessComponentContext() ) );
+ if ( sFontName.isEmpty() )
{
- 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 );
- aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
- SetPointFont( aFont );
- aFont = GetFont();
+ Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
+ sFontName = aTmpFont.GetName();
+ }
+ Size aFontSize(
+ 0,
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::get(
+ comphelper::getProcessComponentContext() ) );
+ Font aFont( sFontName, aFontSize );
+ aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
+ SetPointFont( aFont );
+ aFont = GetFont();
- if ( pModulWindow )
- {
- pModulWindow->GetBreakPointWindow().SetFont( aFont );
- pModulWindow->GetLineNumberWindow().SetFont( aFont );
- }
+ if ( pModulWindow )
+ {
+ pModulWindow->GetBreakPointWindow().SetFont( aFont );
+ pModulWindow->GetLineNumberWindow().SetFont( aFont );
+ }
- if ( pEditEngine )
- {
- sal_Bool bModified = pEditEngine->IsModified();
- pEditEngine->SetFont( aFont );
- pEditEngine->SetModified( bModified );
- }
+ if ( pEditEngine )
+ {
+ sal_Bool bModified = pEditEngine->IsModified();
+ pEditEngine->SetFont( aFont );
+ pEditEngine->SetModified( bModified );
}
}