summaryrefslogtreecommitdiff
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
parentd70aa23c2d3af951c8846b4aea83c87c06a37a35 (diff)
Replace SourceViewConfig with (simplified) direct configuration access.
-rw-r--r--basctl/source/basicide/baside2.hxx24
-rw-r--r--basctl/source/basicide/baside2b.cxx108
-rw-r--r--cui/source/options/fontsubs.cxx42
-rw-r--r--cui/source/options/fontsubs.hxx7
-rw-r--r--dbaccess/source/ui/control/sqledit.cxx86
-rw-r--r--dbaccess/source/ui/inc/sqledit.hxx17
-rw-r--r--sw/source/ui/docvw/srcedtw.cxx84
-rw-r--r--sw/source/ui/inc/srcedtw.hxx23
-rw-r--r--unotools/Library_utl.mk1
-rw-r--r--unotools/Package_inc.mk1
-rw-r--r--unotools/inc/unotools/itemholderbase.hxx1
-rw-r--r--unotools/inc/unotools/sourceviewconfig.hxx62
-rw-r--r--unotools/source/config/itemholder1.cxx5
-rw-r--r--unotools/source/config/sourceviewconfig.cxx242
14 files changed, 290 insertions, 413 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 );
}
}
diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx
index 8e8035461e84..8971cf2bb416 100644
--- a/cui/source/options/fontsubs.cxx
+++ b/cui/source/options/fontsubs.cxx
@@ -26,12 +26,15 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <comphelper/processfactory.hxx>
+#include <officecfg/Office/Common.hxx>
#include <tools/shl.hxx>
#include <svtools/ctrltool.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <svtools/fontsubstconfig.hxx>
-#include <unotools/sourceviewconfig.hxx>
#include "fontsubs.hrc"
#include "fontsubs.hxx"
#include <dialmgr.hxx>
@@ -71,7 +74,6 @@ SvxFontSubstTabPage::SvxFontSubstTabPage( Window* pParent,
sAutomatic (CUI_RES( STR_AUTOMATIC )),
pConfig(new SvtFontSubstConfig),
- pSourceViewConfig(new utl::SourceViewConfig),
sHeader1 (CUI_RES( STR_HEADER1 )),
sHeader2 (CUI_RES( STR_HEADER2 )),
@@ -192,7 +194,6 @@ SvLBoxEntry* SvxFontSubstTabPage::CreateEntry(String& rFont1, String& rFont2)
{
delete pCheckButtonData;
delete pConfig;
- delete pSourceViewConfig;
}
/*********************************************************************/
@@ -230,15 +231,25 @@ sal_Bool SvxFontSubstTabPage::FillItemSet( SfxItemSet& )
if(pConfig->IsModified())
pConfig->Commit();
pConfig->Apply();
+ boost::shared_ptr< unotools::ConfigurationChanges > batch(
+ unotools::ConfigurationChanges::create(
+ comphelper::getProcessComponentContext()));
if(aFontHeightLB.GetSavedValue() != aFontHeightLB.GetSelectEntryPos())
- pSourceViewConfig->SetFontHeight((sal_Int16)aFontHeightLB.GetSelectEntry().ToInt32());
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::set(
+ comphelper::getProcessComponentContext(), batch,
+ static_cast< sal_Int16 >(aFontHeightLB.GetSelectEntry().ToInt32()));
if(aNonPropFontsOnlyCB.GetSavedValue() != aNonPropFontsOnlyCB.IsChecked())
- pSourceViewConfig->SetShowProportionalFontsOnly(aNonPropFontsOnlyCB.IsChecked());
+ officecfg::Office::Common::Font::SourceViewFont::
+ NonProportionalFontsOnly::set(
+ comphelper::getProcessComponentContext(), batch,
+ aNonPropFontsOnlyCB.IsChecked());
//font name changes cannot be detected by saved values
- String sFontName;
+ rtl::OUString sFontName;
if(aFontNameLB.GetSelectEntryPos())
sFontName = aFontNameLB.GetSelectEntry();
- pSourceViewConfig->SetFontName(sFontName);
+ officecfg::Office::Common::Font::SourceViewFont::FontName::set(
+ comphelper::getProcessComponentContext(), batch, sFontName);
+ batch->commit();
return sal_False;
}
@@ -276,15 +287,22 @@ void SvxFontSubstTabPage::Reset( const SfxItemSet& )
aCheckLB.SetUpdateMode(sal_True);
//fill font name box first
- aNonPropFontsOnlyCB.Check(pSourceViewConfig->IsShowProportionalFontsOnly());
+ aNonPropFontsOnlyCB.Check(
+ officecfg::Office::Common::Font::SourceViewFont::
+ NonProportionalFontsOnly::get(
+ comphelper::getProcessComponentContext()));
NonPropFontsHdl(&aNonPropFontsOnlyCB);
- String sFontName(pSourceViewConfig->GetFontName());
- if(sFontName.Len())
+ rtl::OUString sFontName(
+ officecfg::Office::Common::Font::SourceViewFont::FontName::get(
+ comphelper::getProcessComponentContext()));
+ if(!sFontName.isEmpty())
aFontNameLB.SelectEntry(sFontName);
else
aFontNameLB.SelectEntryPos(0);
- short nFontHeight = pSourceViewConfig->GetFontHeight();
- aFontHeightLB.SelectEntry(String::CreateFromInt32(nFontHeight));
+ aFontHeightLB.SelectEntry(
+ String::CreateFromInt32(
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::get(
+ comphelper::getProcessComponentContext())));
aNonPropFontsOnlyCB.SaveValue();
aFontHeightLB.SaveValue();
}
diff --git a/cui/source/options/fontsubs.hxx b/cui/source/options/fontsubs.hxx
index ecd324ea4f63..ad714bdab86a 100644
--- a/cui/source/options/fontsubs.hxx
+++ b/cui/source/options/fontsubs.hxx
@@ -34,11 +34,6 @@
#include <vcl/toolbox.hxx>
#include <svtools/ctrlbox.hxx>
-namespace utl
-{
- class SourceViewConfig;
-}
-
// class SvxFontSubstCheckListBox ------------------------------------------
class SvxFontSubstCheckListBox : public SvxSimpleTable
@@ -71,7 +66,6 @@ class SvxFontSubstCheckListBox : public SvxSimpleTable
// class SvxFontSubstTabPage ----------------------------------------------------
class SvtFontSubstConfig;
-namespace svt {class SourceViewConfig;}
class SvxFontSubstTabPage : public SfxTabPage
{
CheckBox aUseTableCB;
@@ -94,7 +88,6 @@ class SvxFontSubstTabPage : public SfxTabPage
String sAutomatic;
SvtFontSubstConfig* pConfig;
- utl::SourceViewConfig* pSourceViewConfig;
String sHeader1;
String sHeader2;
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
index 3e38a55c5f82..95e31f4ed800 100644
--- a/dbaccess/source/ui/control/sqledit.cxx
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -26,6 +26,14 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "com/sun/star/beans/XMultiPropertySet.hpp"
+#include "com/sun/star/beans/XPropertiesChangeListener.hpp"
+#include "comphelper/processfactory.hxx"
+#include "officecfg/Office/Common.hxx"
#include "sqledit.hxx"
#include "QueryTextView.hxx"
#include "querycontainerwindow.hxx"
@@ -38,11 +46,44 @@
#include <svl/smplhint.hxx>
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
//////////////////////////////////////////////////////////////////////////
// OSqlEdit
//------------------------------------------------------------------------------
using namespace dbaui;
+class OSqlEdit::ChangesListener:
+ public cppu::WeakImplHelper1< css::beans::XPropertiesChangeListener >
+{
+public:
+ ChangesListener(OSqlEdit & editor): editor_(editor) {}
+
+private:
+ virtual ~ChangesListener() {}
+
+ virtual void disposing(css::lang::EventObject const &)
+ throw (css::uno::RuntimeException)
+ {
+ osl::MutexGuard g(editor_.m_mutex);
+ editor_.m_notifier.clear();
+ }
+
+ virtual void propertiesChange(
+ css::uno::Sequence< css::beans::PropertyChangeEvent > const &)
+ throw (css::uno::RuntimeException)
+ {
+ SolarMutexGuard g;
+ editor_.ImplSetFont();
+ }
+
+ OSqlEdit & editor_;
+};
+
DBG_NAME(OSqlEdit)
OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) :
MultiLineEditSyntaxHighlight( pParent, nWinStyle )
@@ -62,8 +103,22 @@ OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) :
m_timerInvalidate.Start();
ImplSetFont();
- // listen for change of Font and Color Settings
- m_SourceViewConfig.AddListener( this );
+ // Listen for change of Font and Color Settings:
+ // Using "this" in ctor is a little fishy, but should work here at least as
+ // long as there are no derivations:
+ m_listener = new ChangesListener(*this);
+ css::uno::Reference< css::beans::XMultiPropertySet > n(
+ officecfg::Office::Common::Font::SourceViewFont::get(
+ comphelper::getProcessComponentContext()),
+ css::uno::UNO_QUERY_THROW);
+ {
+ osl::MutexGuard g(m_mutex);
+ m_notifier = n;
+ }
+ css::uno::Sequence< rtl::OUString > s(2);
+ s[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontHeight"));
+ s[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontName"));
+ n->addPropertiesChangeListener(s, m_listener.get());
m_ColorConfig.AddListener(this);
//#i97044#
@@ -76,7 +131,14 @@ OSqlEdit::~OSqlEdit()
DBG_DTOR(OSqlEdit,NULL);
if (m_timerUndoActionCreation.IsActive())
m_timerUndoActionCreation.Stop();
- m_SourceViewConfig.RemoveListener(this);
+ css::uno::Reference< css::beans::XMultiPropertySet > n;
+ {
+ osl::MutexGuard g(m_mutex);
+ n = m_notifier;
+ }
+ if (n.is()) {
+ n->removePropertiesChangeListener(m_listener.get());
+ }
m_ColorConfig.RemoveListener(this);
}
//------------------------------------------------------------------------------
@@ -198,23 +260,27 @@ void OSqlEdit::startTimer()
void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, sal_uInt32 )
{
- if ( pOption == &m_SourceViewConfig )
- ImplSetFont();
- else if ( pOption == &m_ColorConfig )
- MultiLineEditSyntaxHighlight::UpdateData();
+ assert( pOption == &m_ColorConfig );
+ (void) pOption; // avoid warnings
+ MultiLineEditSyntaxHighlight::UpdateData();
}
void OSqlEdit::ImplSetFont()
{
AllSettings aSettings = GetSettings();
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
- String sFontName = m_SourceViewConfig.GetFontName();
- if ( !sFontName.Len() )
+ rtl::OUString sFontName(
+ officecfg::Office::Common::Font::SourceViewFont::FontName::get(
+ comphelper::getProcessComponentContext() ) );
+ if ( sFontName.isEmpty() )
{
Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
sFontName = aTmpFont.GetName();
}
- Size aFontSize( 0, m_SourceViewConfig.GetFontHeight() );
+ Size aFontSize(
+ 0,
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::get(
+ comphelper::getProcessComponentContext() ) );
Font aFont( sFontName, aFontSize );
aStyleSettings.SetFieldFont(aFont);
aSettings.SetStyleSettings(aStyleSettings);
diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx
index 2e98ce3ac3c6..f2d682d189af 100644
--- a/dbaccess/source/ui/inc/sqledit.hxx
+++ b/dbaccess/source/ui/inc/sqledit.hxx
@@ -28,10 +28,16 @@
#ifndef DBAUI_SQLEDIT_HXX
#define DBAUI_SQLEDIT_HXX
+#include "sal/config.h"
+
+#include <rtl/ref.hxx>
#include <svtools/editsyntaxhighlighter.hxx>
#include <svl/lstner.hxx>
#include <svtools/colorcfg.hxx>
-#include <unotools/sourceviewconfig.hxx>
+
+namespace com { namespace sun { namespace star { namespace beans {
+ class XMultiPropertySet;
+} } } }
namespace dbaui
{
@@ -39,6 +45,9 @@ namespace dbaui
class OSqlEdit : public MultiLineEditSyntaxHighlight, utl::ConfigurationListener
{
private:
+ class ChangesListener;
+ friend class ChangesListener;
+
Timer m_timerInvalidate;
Timer m_timerUndoActionCreation;
Link m_lnkTextModifyHdl;
@@ -46,9 +55,13 @@ namespace dbaui
OQueryTextView* m_pView;
sal_Bool m_bAccelAction; // Wird bei Cut, Copy, Paste gesetzt
sal_Bool m_bStopTimer;
- utl::SourceViewConfig m_SourceViewConfig;
svtools::ColorConfig m_ColorConfig;
+ rtl::Reference< ChangesListener > m_listener;
+ osl::Mutex m_mutex;
+ com::sun::star::uno::Reference<
+ com::sun::star::beans::XMultiPropertySet > m_notifier;
+
DECL_LINK(OnUndoActionTimer, void*);
DECL_LINK(OnInvalidateTimer, void*);
diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx
index ec30d62e1ce6..fb874080fd34 100644
--- a/sw/source/ui/docvw/srcedtw.cxx
+++ b/sw/source/ui/docvw/srcedtw.cxx
@@ -26,11 +26,16 @@
*
************************************************************************/
-
+#include "sal/config.h"
#include <hintids.hxx>
#include <cmdid.h>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <officecfg/Office/Common.hxx>
#include <rtl/oustringostreaminserter.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -41,7 +46,6 @@
#include <sfx2/app.hxx>
#include <svtools/htmltokn.h>
#include <svtools/txtattr.hxx>
-#include <unotools/sourceviewconfig.hxx>
#include <svtools/colorcfg.hxx>
#include <editeng/flstitem.hxx>
#include <vcl/metric.hxx>
@@ -53,7 +57,11 @@
#include <helpid.h>
#include <deque>
+namespace {
+
+namespace css = com::sun::star;
+}
struct SwTextPortion
{
@@ -214,6 +222,33 @@ static void lcl_Highlight(const String& rSource, SwTextPortions& aPortionList)
}
}
+class SwSrcEditWindow::ChangesListener:
+ public cppu::WeakImplHelper1< css::beans::XPropertiesChangeListener >
+{
+public:
+ ChangesListener(SwSrcEditWindow & editor): editor_(editor) {}
+
+private:
+ virtual ~ChangesListener() {}
+
+ virtual void disposing(css::lang::EventObject const &)
+ throw (css::uno::RuntimeException)
+ {
+ osl::MutexGuard g(editor_.mutex_);
+ editor_.notifier_.clear();
+ }
+
+ virtual void propertiesChange(
+ css::uno::Sequence< css::beans::PropertyChangeEvent > const &)
+ throw (css::uno::RuntimeException)
+ {
+ SolarMutexGuard g;
+ editor_.SetFont();
+ }
+
+ SwSrcEditWindow & editor_;
+};
+
SwSrcEditWindow::SwSrcEditWindow( Window* pParent, SwSrcView* pParentView ) :
Window( pParent, WB_BORDER|WB_CLIPCHILDREN ),
@@ -224,7 +259,6 @@ SwSrcEditWindow::SwSrcEditWindow( Window* pParent, SwSrcView* pParentView ) :
pVScrollbar(0),
pSrcView(pParentView),
- pSourceViewConfig(new utl::SourceViewConfig),
nCurTextWidth(0),
nStartLine(USHRT_MAX),
@@ -234,13 +268,34 @@ SwSrcEditWindow::SwSrcEditWindow( Window* pParent, SwSrcView* pParentView ) :
{
SetHelpId(HID_SOURCE_EDITWIN);
CreateTextEngine();
- 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);
+ css::uno::Reference< css::beans::XMultiPropertySet > n(
+ officecfg::Office::Common::Font::SourceViewFont::get(
+ comphelper::getProcessComponentContext()),
+ css::uno::UNO_QUERY_THROW);
+ {
+ osl::MutexGuard g(mutex_);
+ notifier_ = n;
+ }
+ css::uno::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());
}
SwSrcEditWindow::~SwSrcEditWindow()
{
- pSourceViewConfig->RemoveListener(this);
- delete pSourceViewConfig;
+ css::uno::Reference< css::beans::XMultiPropertySet > n;
+ {
+ osl::MutexGuard g(mutex_);
+ n = notifier_;
+ }
+ if (n.is()) {
+ n->removePropertiesChangeListener(listener_.get());
+ }
aSyntaxIdleTimer.Stop();
if ( pTextEngine )
{
@@ -724,12 +779,6 @@ void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
-void SwSrcEditWindow::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal_uInt32 )
-{
- if( pBrdCst == pSourceViewConfig)
- SetFont();
-}
-
void SwSrcEditWindow::Invalidate(sal_uInt16 )
{
pOutWin->Invalidate();
@@ -928,8 +977,10 @@ sal_Bool lcl_GetLanguagesForEncoding(rtl_TextEncoding eEnc, LanguageType aLangu
}
void SwSrcEditWindow::SetFont()
{
- String sFontName = pSourceViewConfig->GetFontName();
- if(!sFontName.Len())
+ rtl::OUString sFontName(
+ officecfg::Office::Common::Font::SourceViewFont::FontName::get(
+ comphelper::getProcessComponentContext()));
+ if(sFontName.isEmpty())
{
LanguageType aLanguages[5] =
{
@@ -955,7 +1006,10 @@ void SwSrcEditWindow::SetFont()
Font aFont(aInfo);
Size aSize(rFont.GetSize());
//font height is stored in point and set in twip
- aSize.Height() = pSourceViewConfig->GetFontHeight() * 20;
+ aSize.Height() =
+ officecfg::Office::Common::Font::SourceViewFont::FontHeight::get(
+ comphelper::getProcessComponentContext())
+ * 20;
aFont.SetSize(pOutWin->LogicToPixel(aSize, MAP_TWIP));
GetTextEngine()->SetFont( aFont );
pOutWin->SetFont(aFont);
diff --git a/sw/source/ui/inc/srcedtw.hxx b/sw/source/ui/inc/srcedtw.hxx
index 9e9a74f900af..3439b19478ba 100644
--- a/sw/source/ui/inc/srcedtw.hxx
+++ b/sw/source/ui/inc/srcedtw.hxx
@@ -30,12 +30,15 @@
#include <vcl/window.hxx>
#include <svl/lstner.hxx>
-#include <unotools/options.hxx>
#include <vcl/timer.hxx>
#include <tools/table.hxx>
#include <svtools/xtextedt.hxx>
+namespace com { namespace sun { namespace star { namespace beans {
+ class XMultiPropertySet;
+} } } }
+
class ScrollBar;
class SwSrcView;
class SwSrcEditWindow;
@@ -43,11 +46,6 @@ class TextEngine;
class ExtTextView;
class DataChangedEvent;
-namespace utl
-{
- class SourceViewConfig;
-}
-
class TextViewOutWin : public Window
{
ExtTextView* pTextView;
@@ -70,10 +68,12 @@ public:
};
//------------------------------------------------------------
-namespace svt{ class SourceViewConfig;}
-class SwSrcEditWindow : public Window, public SfxListener, public utl::ConfigurationListener
+class SwSrcEditWindow : public Window, public SfxListener
{
private:
+ class ChangesListener;
+ friend class ChangesListener;
+
ExtTextView* pTextView;
ExtTextEngine* pTextEngine;
@@ -82,7 +82,11 @@ private:
*pVScrollbar;
SwSrcView* pSrcView;
- utl::SourceViewConfig* pSourceViewConfig;
+
+ rtl::Reference< ChangesListener > listener_;
+ osl::Mutex mutex_;
+ com::sun::star::uno::Reference< com::sun::star::beans::XMultiPropertySet >
+ notifier_;
long nCurTextWidth;
sal_uInt16 nStartLine;
@@ -116,7 +120,6 @@ protected:
void DoSyntaxHighlight( sal_uInt16 nPara );
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
- virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 );
DECL_LINK(ScrollHdl, ScrollBar*);
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk
index 01571459d571..2b68a95d65ee 100644
--- a/unotools/Library_utl.mk
+++ b/unotools/Library_utl.mk
@@ -106,7 +106,6 @@ $(eval $(call gb_Library_add_exception_objects,utl,\
unotools/source/config/saveopt \
unotools/source/config/searchopt \
unotools/source/config/securityoptions \
- unotools/source/config/sourceviewconfig \
unotools/source/config/startoptions \
unotools/source/config/syslocaleoptions \
unotools/source/config/undoopt \
diff --git a/unotools/Package_inc.mk b/unotools/Package_inc.mk
index 7d031fbb76fb..41a2aa132cfd 100644
--- a/unotools/Package_inc.mk
+++ b/unotools/Package_inc.mk
@@ -89,7 +89,6 @@ $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/saveopt.hxx,unotools
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/searchopt.hxx,unotools/searchopt.hxx))
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/securityoptions.hxx,unotools/securityoptions.hxx))
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/sharedunocomponent.hxx,unotools/sharedunocomponent.hxx))
-$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/sourceviewconfig.hxx,unotools/sourceviewconfig.hxx))
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/startoptions.hxx,unotools/startoptions.hxx))
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/streamhelper.hxx,unotools/streamhelper.hxx))
$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/streamsection.hxx,unotools/streamsection.hxx))
diff --git a/unotools/inc/unotools/itemholderbase.hxx b/unotools/inc/unotools/itemholderbase.hxx
index 8f14f9a17f11..fa9ed48b5f78 100644
--- a/unotools/inc/unotools/itemholderbase.hxx
+++ b/unotools/inc/unotools/itemholderbase.hxx
@@ -97,7 +97,6 @@ enum EItem
E_SAVEOPTIONS , //
E_SEARCHOPT , //
E_SECURITYOPTIONS , //
- E_SOURCEVIEWCONFIG , //
E_STARTOPTIONS , //
E_SYSLOCALEOPTIONS , // 2
diff --git a/unotools/inc/unotools/sourceviewconfig.hxx b/unotools/inc/unotools/sourceviewconfig.hxx
deleted file mode 100644
index 02b2ab0ab79b..000000000000
--- a/unotools/inc/unotools/sourceviewconfig.hxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef _unotools_SOURCEVIEWCONFIG_HXX
-#define _unotools_SOURCEVIEWCONFIG_HXX
-
-// include ---------------------------------------------------------------
-
-#include "unotools/unotoolsdllapi.h"
-#include <osl/mutex.hxx>
-#include <rtl/ustring.hxx>
-#include <unotools/options.hxx>
-
-namespace utl
-{
- class SourceViewConfig_Impl;
- class UNOTOOLS_DLLPUBLIC SourceViewConfig: public utl::detail::Options
- {
- static SourceViewConfig_Impl* m_pImplConfig;
- static sal_Int32 m_nRefCount;
-
- public:
- SourceViewConfig();
- virtual ~SourceViewConfig();
-
- const rtl::OUString& GetFontName() const;
- void SetFontName(const rtl::OUString& rName);
-
- sal_Int16 GetFontHeight() const;
- void SetFontHeight(sal_Int16 nHeight);
-
- sal_Bool IsShowProportionalFontsOnly() const;
- void SetShowProportionalFontsOnly(sal_Bool bSet);
- };
-}
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx
index c20128bf4773..8eee7ba1b00a 100644
--- a/unotools/source/config/itemholder1.cxx
+++ b/unotools/source/config/itemholder1.cxx
@@ -59,7 +59,6 @@
#include <unotools/saveopt.hxx>
#include <unotools/searchopt.hxx>
#include <unotools/securityoptions.hxx>
-#include <unotools/sourceviewconfig.hxx>
#include <unotools/startoptions.hxx>
#include <unotools/viewoptions.hxx>
#include <unotools/workingsetoptions.hxx>
@@ -263,10 +262,6 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem)
rItem.pItem = new SvtSecurityOptions();
break;
- case E_SOURCEVIEWCONFIG :
- rItem.pItem = new ::utl::SourceViewConfig();
- break;
-
case E_STARTOPTIONS :
rItem.pItem = new SvtStartOptions();
break;
diff --git a/unotools/source/config/sourceviewconfig.cxx b/unotools/source/config/sourceviewconfig.cxx
deleted file mode 100644
index 7f5bdbe5d428..000000000000
--- a/unotools/source/config/sourceviewconfig.cxx
+++ /dev/null
@@ -1,242 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <unotools/sourceviewconfig.hxx>
-#include <com/sun/star/uno/Any.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <unotools/configitem.hxx>
-#include <tools/debug.hxx>
-#include <rtl/instance.hxx>
-
-#include <itemholder1.hxx>
-
-using namespace utl;
-using namespace com::sun::star::uno;
-
-using ::rtl::OUString;
-
-namespace utl
-{
-class SourceViewConfig_Impl : public utl::ConfigItem
-{
-private:
- OUString m_sFontName;
- sal_Int16 m_nFontHeight;
- sal_Bool m_bProportionalFontOnly;
-
- void Load();
-
- static Sequence< OUString > GetPropertyNames();
-
-public:
- SourceViewConfig_Impl();
- ~SourceViewConfig_Impl();
-
- virtual void Notify( const Sequence< rtl::OUString >& aPropertyNames );
- virtual void Commit();
-
- const rtl::OUString& GetFontName() const
- {return m_sFontName;}
- void SetFontName(const rtl::OUString& rName)
- {
- if(rName != m_sFontName)
- {
- m_sFontName = rName;
- SetModified();
- }
- }
-
- sal_Int16 GetFontHeight() const
- {return m_nFontHeight;}
- void SetFontHeight(sal_Int16 nHeight)
- {
- if(m_nFontHeight != nHeight)
- {
- m_nFontHeight = nHeight;
- SetModified();
- }
- }
-
- sal_Bool IsShowProportionalFontsOnly() const
- {return m_bProportionalFontOnly;}
- void SetShowProportionalFontsOnly(sal_Bool bSet)
- {
- if(m_bProportionalFontOnly != bSet)
- {
- m_bProportionalFontOnly = bSet;
- SetModified();
- }
- }
-};
-// initialization of static members --------------------------------------
-SourceViewConfig_Impl* SourceViewConfig::m_pImplConfig = 0;
-sal_Int32 SourceViewConfig::m_nRefCount = 0;
-namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; }
-
-SourceViewConfig_Impl::SourceViewConfig_Impl() :
- ConfigItem(OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Font/SourceViewFont"))),
- m_nFontHeight(12),
- m_bProportionalFontOnly(sal_False)
-{
- Load();
-}
-
-SourceViewConfig_Impl::~SourceViewConfig_Impl()
-{
-}
-
-Sequence< OUString > SourceViewConfig_Impl::GetPropertyNames()
-{
- //this list needs exactly to mach the enum PropertyNameIndex
- static const char* aPropNames[] =
- {
- "FontName" // 0
- ,"FontHeight" // 1
- ,"NonProportionalFontsOnly" // 2
- };
- const int nCount = sizeof( aPropNames ) / sizeof( const char* );
- Sequence< OUString > aNames( nCount );
- OUString* pNames = aNames.getArray();
- for ( int i = 0; i < nCount; i++ )
- pNames[i] = OUString::createFromAscii( aPropNames[i] );
-
- return aNames;
-}
-
-void SourceViewConfig_Impl::Load()
-{
- Sequence< OUString > aNames = GetPropertyNames();
- Sequence< Any > aValues = GetProperties( aNames );
- EnableNotification( aNames );
- const Any* pValues = aValues.getConstArray();
- DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
- if ( aValues.getLength() == aNames.getLength() )
- {
- for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
- {
- if ( pValues[nProp].hasValue() )
- {
- switch( nProp )
- {
- case 0: pValues[nProp] >>= m_sFontName; break;
- case 1: pValues[nProp] >>= m_nFontHeight; break;
- case 2: pValues[nProp] >>= m_bProportionalFontOnly; break;
- }
- }
- }
- }
-}
-
-void SourceViewConfig_Impl::Notify( const Sequence< OUString >& )
-{
- Load();
-}
-
-void SourceViewConfig_Impl::Commit()
-{
- ClearModified();
- Sequence< OUString > aNames = GetPropertyNames();
- Sequence< Any > aValues( aNames.getLength() );
- Any* pValues = aValues.getArray();
- for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
- {
- switch( nProp )
- {
- case 0: pValues[nProp] <<= m_sFontName; break;
- case 1: pValues[nProp] <<= m_nFontHeight; break;
- case 2: pValues[nProp] <<= m_bProportionalFontOnly; break;
- default:
- SAL_WARN( "unotools.config", "invalid index to save a user token" );
- }
- }
- PutProperties( aNames, aValues );
-
- NotifyListeners(0);
-}
-
-SourceViewConfig::SourceViewConfig()
-{
- {
- ::osl::MutexGuard aGuard( lclMutex::get() );
- if(!m_pImplConfig)
- {
- m_pImplConfig = new SourceViewConfig_Impl;
- ItemHolder1::holdConfigItem(E_SOURCEVIEWCONFIG);
- }
-
- ++m_nRefCount;
- }
-
- m_pImplConfig->AddListener( this );
-}
-
-SourceViewConfig::~SourceViewConfig()
-{
- m_pImplConfig->RemoveListener( this );
- ::osl::MutexGuard aGuard( lclMutex::get() );
- if( !--m_nRefCount )
- {
- if( m_pImplConfig->IsModified() )
- m_pImplConfig->Commit();
- DELETEZ( m_pImplConfig );
- }
-}
-
-const OUString& SourceViewConfig::GetFontName() const
-{
- return m_pImplConfig->GetFontName();
-}
-
-void SourceViewConfig::SetFontName(const OUString& rName)
-{
- m_pImplConfig->SetFontName(rName);
-}
-
-sal_Int16 SourceViewConfig::GetFontHeight() const
-{
- return m_pImplConfig->GetFontHeight();
-}
-
-void SourceViewConfig::SetFontHeight(sal_Int16 nHeight)
-{
- m_pImplConfig->SetFontHeight(nHeight);
-}
-
-sal_Bool SourceViewConfig::IsShowProportionalFontsOnly() const
-{
- return m_pImplConfig->IsShowProportionalFontsOnly();
-}
-
-void SourceViewConfig::SetShowProportionalFontsOnly(sal_Bool bSet)
-{
- m_pImplConfig->SetShowProportionalFontsOnly(bSet);
-}
-}
-// namespace utl
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */