[Libreoffice-commits] .: 3 commits - basctl/source cui/source dbaccess/source offapi/com officecfg/registry sw/source unotools/inc unotools/Library_utl.mk unotools/Package_inc.mk unotools/source
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Wed Jan 25 09:20:01 PST 2012
basctl/source/basicide/baside2.hxx | 24 -
basctl/source/basicide/baside2b.cxx | 108 +++++---
cui/source/options/fontsubs.cxx | 42 ++-
cui/source/options/fontsubs.hxx | 7
dbaccess/source/ui/control/sqledit.cxx | 86 +++++-
dbaccess/source/ui/inc/sqledit.hxx | 17 +
offapi/com/sun/star/configuration/ReadOnlyAccess.idl | 2
officecfg/registry/cppheader.xsl | 24 +
sw/source/ui/docvw/srcedtw.cxx | 84 +++++-
sw/source/ui/inc/srcedtw.hxx | 23 +
unotools/Library_utl.mk | 1
unotools/Package_inc.mk | 1
unotools/inc/unotools/configuration.hxx | 48 +++
unotools/inc/unotools/itemholderbase.hxx | 1
unotools/inc/unotools/sourceviewconfig.hxx | 62 ----
unotools/source/config/configuration.cxx | 25 +
unotools/source/config/itemholder1.cxx | 5
unotools/source/config/sourceviewconfig.cxx | 242 -------------------
18 files changed, 384 insertions(+), 418 deletions(-)
New commits:
commit a2195b2dc301a6c2cfd0bf1a7ff74483bcc5998a
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 25 18:18:18 2012 +0100
Replace SourceViewConfig with (simplified) direct configuration access.
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 8d5aab9..a44e02b 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 52f9752..101fcfd 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 8e80354..8971cf2 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 ecd324e..ad714bd 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 3e38a55..95e31f4 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 2e98ce3..f2d682d 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 ec30d62..fb87408 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 9e9a74f..3439b19 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 0157145..2b68a95 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 7d031fb..41a2aa1 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 8f14f9a..fa9ed48 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 02b2ab0..0000000
--- 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 c20128b..8eee7ba 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 7f5bdbe..0000000
--- 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: */
commit d70aa23c2d3af951c8846b4aea83c87c06a37a35
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 25 18:17:08 2012 +0100
Add configuration wrappers for groups, too (to add listeners etc.).
diff --git a/officecfg/registry/cppheader.xsl b/officecfg/registry/cppheader.xsl
index df891c2..2522aca 100644
--- a/officecfg/registry/cppheader.xsl
+++ b/officecfg/registry/cppheader.xsl
@@ -141,9 +141,18 @@
<xsl:template match="group">
<xsl:param name="path"/>
<xsl:if test=".//prop or .//set">
- <xsl:text>namespace </xsl:text>
- <xsl:value-of select="translate(@oor:name, '-.', '__')"/>
- <xsl:text> {
</xsl:text>
+ <xsl:variable name="name" select="translate(@oor:name, '-.', '__')"/>
+ <xsl:text>struct </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>: public unotools::ConfigurationGroup< </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>> {
</xsl:text>
+ <xsl:text> static rtl::OUString path() { return rtl::OUString(<!--
+ -->RTL_CONSTASCII_USTRINGPARAM("</xsl:text>
+ <xsl:value-of select="$path"/>
+ <xsl:text>/</xsl:text>
+ <xsl:value-of select="@oor:name"/>
+ <xsl:text>")); }
</xsl:text>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="group|set|prop">
<xsl:with-param name="path">
@@ -152,7 +161,14 @@
<xsl:value-of select="@oor:name"/>
</xsl:with-param>
</xsl:apply-templates>
- <xsl:text>}
</xsl:text>
+ <xsl:text>private:
</xsl:text>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined
</xsl:text>
+ <xsl:text> ~</xsl:text>
+ <xsl:value-of select="$name"/>
+ <xsl:text>(); // not defined
</xsl:text>
+ <xsl:text>};
</xsl:text>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:template>
diff --git a/unotools/inc/unotools/configuration.hxx b/unotools/inc/unotools/configuration.hxx
index c9969c8..cfcc7e7 100644
--- a/unotools/inc/unotools/configuration.hxx
+++ b/unotools/inc/unotools/configuration.hxx
@@ -43,6 +43,7 @@ namespace com { namespace sun { namespace star {
namespace configuration { class XReadWriteAccess; }
namespace container {
class XHierarchicalNameAccess;
+ class XHierarchicalNameReplace;
class XNameAccess;
class XNameContainer;
}
@@ -80,6 +81,10 @@ private:
rtl::OUString const & path, com::sun::star::uno::Any const & value)
const;
+ SAL_DLLPRIVATE com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameReplace >
+ getGroup(rtl::OUString const & path) const;
+
SAL_DLLPRIVATE
com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >
getSet(rtl::OUString const & path) const;
@@ -120,6 +125,16 @@ public:
rtl::OUString const & path, com::sun::star::uno::Any const & value)
const;
+ com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess >
+ getGroupReadOnly(rtl::OUString const & path) const;
+
+ com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameReplace >
+ getGroupReadWrite(
+ boost::shared_ptr< ConfigurationChanges > const & batch,
+ rtl::OUString const & path) const;
+
com::sun::star::uno::Reference< com::sun::star::container::XNameAccess >
getSetReadOnly(rtl::OUString const & path) const;
@@ -230,6 +245,39 @@ private:
~ConfigurationLocalizedProperty(); // not defined
};
+/// A type-safe wrapper around a configuration group.
+///
+/// Automatically generated headers for the various configuration groups derive
+/// from this template and make available its member functions to access each
+/// given configuration group.
+template< typename T > struct ConfigurationGroup: private boost::noncopyable {
+ /// Get read-only access to the given configuration group.
+ static com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameAccess >
+ get(com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & context)
+ {
+ return detail::ConfigurationWrapper::get(context).getGroupReadOnly(
+ T::path());
+ }
+
+ /// Get read/write access to the given configuration group, storing any
+ /// modifications via the given changes batch.
+ static com::sun::star::uno::Reference<
+ com::sun::star::container::XHierarchicalNameReplace >
+ get(com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+ const & context,
+ boost::shared_ptr< ConfigurationChanges > const & batch)
+ {
+ return detail::ConfigurationWrapper::get(context).getGroupReadWrite(
+ batch, T::path());
+ }
+
+private:
+ ConfigurationGroup(); // not defined
+ ~ConfigurationGroup(); // not defined
+};
+
/// A type-safe wrapper around a configuration set.
///
/// Automatically generated headers for the various configuration sets derive
diff --git a/unotools/source/config/configuration.cxx b/unotools/source/config/configuration.cxx
index a4b30ed..a8c818c 100644
--- a/unotools/source/config/configuration.cxx
+++ b/unotools/source/config/configuration.cxx
@@ -37,6 +37,7 @@
#include "com/sun/star/configuration/XReadWriteAccess.hpp"
#include "com/sun/star/configuration/theDefaultProvider.hpp"
#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/container/XHierarchicalNameReplace.hpp"
#include "com/sun/star/container/XNameAccess.hpp"
#include "com/sun/star/container/XNameContainer.hpp"
#include "com/sun/star/lang/Locale.hpp"
@@ -90,6 +91,13 @@ void unotools::ConfigurationChanges::setPropertyValue(
access_->replaceByHierarchicalName(path, value);
}
+css::uno::Reference< css::container::XHierarchicalNameReplace >
+unotools::ConfigurationChanges::getGroup(rtl::OUString const & path) const
+{
+ return css::uno::Reference< css::container::XHierarchicalNameReplace >(
+ access_->getByHierarchicalName(path), css::uno::UNO_QUERY_THROW);
+}
+
css::uno::Reference< css::container::XNameContainer >
unotools::ConfigurationChanges::getSet(rtl::OUString const & path) const
{
@@ -139,6 +147,23 @@ void unotools::detail::ConfigurationWrapper::setLocalizedPropertyValue(
batch->setPropertyValue(extendLocalizedPath(path), value);
}
+css::uno::Reference< css::container::XHierarchicalNameAccess >
+unotools::detail::ConfigurationWrapper::getGroupReadOnly(
+ rtl::OUString const & path) const
+{
+ return css::uno::Reference< css::container::XHierarchicalNameAccess >(
+ access_->getByHierarchicalName(path), css::uno::UNO_QUERY_THROW);
+}
+
+css::uno::Reference< css::container::XHierarchicalNameReplace >
+unotools::detail::ConfigurationWrapper::getGroupReadWrite(
+ boost::shared_ptr< ConfigurationChanges > const & batch,
+ rtl::OUString const & path) const
+{
+ assert(batch.get() != 0);
+ return batch->getGroup(path);
+}
+
css::uno::Reference< css::container::XNameAccess >
unotools::detail::ConfigurationWrapper::getSetReadOnly(
rtl::OUString const & path) const
commit 866df124ee89a9d7b1f2b7803892f02c1010a9be
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 25 18:15:16 2012 +0100
typo
diff --git a/offapi/com/sun/star/configuration/ReadOnlyAccess.idl b/offapi/com/sun/star/configuration/ReadOnlyAccess.idl
index 06e2a33..aaeb6da 100644
--- a/offapi/com/sun/star/configuration/ReadOnlyAccess.idl
+++ b/offapi/com/sun/star/configuration/ReadOnlyAccess.idl
@@ -34,7 +34,7 @@
module com { module sun { module star { module configuration {
-/* Provides easy read/write access to the complete configuration.
+/* Provides easy read-only access to the complete configuration.
<p>This singleton is still unpublished and unstable.</p>
More information about the Libreoffice-commits
mailing list