summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-03 04:33:07 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-11 08:01:23 +0200
commit6030a11ce58761a9b3399c1152da76779d1e88b4 (patch)
tree3b735aebbd1af6510b72f0110904fbf771b22d67
parentsolve more dependencies between ui elements in cond format dialog (diff)
downloadcore-6030a11ce58761a9b3399c1152da76779d1e88b4.tar.gz
core-6030a11ce58761a9b3399c1152da76779d1e88b4.zip
handle styles correctly in the new cond format dialog
Change-Id: I285efa3ec455fd35afd00aa5daa2c722fe7d277b
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx58
-rw-r--r--sc/source/ui/inc/condformatdlg.hxx1
2 files changed, 59 insertions, 0 deletions
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 648debbaa2ca..f7bbbfb0b98a 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -31,11 +31,17 @@
#include <vcl/vclevent.hxx>
#include <svl/style.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
#include "anyrefdg.hxx"
#include "document.hxx"
#include "conditio.hxx"
#include "stlpool.hxx"
+#include "tabvwsh.hxx"
+
+#include "globstr.hrc"
#include <iostream>
@@ -84,6 +90,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
}
maLbStyle.SetSeparatorPos(0);
maLbStyle.SelectEntryPos(1);
+ maLbStyle.SetSelectHdl( LINK( this, ScCondFrmtEntry, StyleSelectHdl ) );
//disable entries for color formats
maLbColorFormat.SelectEntryPos(0);
@@ -344,6 +351,57 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, ColFormatTypeHdl)
return 0;
}
+IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
+{
+ if(maLbStyle.GetSelectEntryPos() == 0)
+ {
+ // call new style dialog
+ SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
+ SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
+
+ // unlock the dispatcher so SID_STYLE_NEW can be executed
+ // (SetDispatcherLock would affect all Calc documents)
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SfxDispatcher* pDisp = pViewShell->GetDispatcher();
+ sal_Bool bLocked = pDisp->IsLocked();
+ if (bLocked)
+ pDisp->Lock(false);
+
+ // Execute the "new style" slot, complete with undo and all necessary updates.
+ // The return value (SfxUInt16Item) is ignored, look for new styles instead.
+ pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
+ &aFamilyItem,
+ &aRefItem,
+ 0L );
+
+ if (bLocked)
+ pDisp->Lock(sal_True);
+
+ // Find the new style and add it into the style list boxes
+ rtl::OUString aNewStyle;
+ SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+ for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
+ {
+ rtl::OUString aName = pStyle->GetName();
+ if ( maLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries
+ {
+ maLbStyle.InsertEntry(aName);
+ maLbStyle.SelectEntry(aName);
+ }
+ }
+ }
+
+ rtl::OUString aStyleName = maLbStyle.GetSelectEntry();
+ SfxStyleSheetBase* pStyleSheet = mpDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+ if(pStyleSheet)
+ {
+ const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ maWdPreview.Init( rSet );
+ }
+
+ return 0;
+}
+
ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc):
Control(pParent, rResId),
mbHasScrollBar(false),
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index b9c113239a94..4a804e4e4b9c 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -102,6 +102,7 @@ private:
DECL_LINK( TypeListHdl, void*);
DECL_LINK( ColFormatTypeHdl, void*);
+ DECL_LINK( StyleSelectHdl, void* );
public:
ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );