[Libreoffice-commits] .: 6 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Nov 18 13:21:06 PST 2011
sc/source/ui/cctrl/checklistmenu.cxx | 30 +++++--
sc/source/ui/inc/checklistmenu.hxx | 15 ++-
sc/source/ui/inc/gridwin.hxx | 5 -
sc/source/ui/view/gridwin.cxx | 142 +++++++++++++++++++++--------------
4 files changed, 124 insertions(+), 68 deletions(-)
New commits:
commit 43cab25e27f944fedae0e19eecd072914817016f
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 16:20:24 2011 -0500
Get top10, empty and non-empty special queries to work.
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 884d5c6..cb351dc 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -757,7 +757,7 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
ScQueryParam aParam;
pDBData->GetQueryParam(aParam);
- if (mpAutoFilterPopup->isAllSelected())
+ if (eMode == Normal && mpAutoFilterPopup->isAllSelected())
{
// Remove this entry.
aParam.RemoveEntryByField(rPos.Col());
@@ -775,19 +775,42 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
pEntry->nField = rPos.Col();
pEntry->eConnect = SC_AND;
- ScCheckListMenuWindow::ResultType aResult;
- mpAutoFilterPopup->getResult(aResult);
- std::vector<rtl::OUString> aSelected;
- ScCheckListMenuWindow::ResultType::const_iterator itr = aResult.begin(), itrEnd = aResult.end();
- for (; itr != itrEnd; ++itr)
+ switch (eMode)
{
- if (itr->second)
- aSelected.push_back(itr->first);
- }
+ case Normal:
+ {
+ pEntry->eOp = SC_EQUAL;
+
+ ScCheckListMenuWindow::ResultType aResult;
+ mpAutoFilterPopup->getResult(aResult);
+ std::vector<rtl::OUString> aSelected;
+ ScCheckListMenuWindow::ResultType::const_iterator itr = aResult.begin(), itrEnd = aResult.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ if (itr->second)
+ aSelected.push_back(itr->first);
+ }
- ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
- rItems.clear();
- std::for_each(aSelected.begin(), aSelected.end(), AddItemToEntry(rItems));
+ ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
+ rItems.clear();
+ std::for_each(aSelected.begin(), aSelected.end(), AddItemToEntry(rItems));
+ }
+ break;
+ case Top10:
+ pEntry->eOp = SC_TOPVAL;
+ pEntry->GetQueryItem().meType = ScQueryEntry::ByString;
+ pEntry->GetQueryItem().maString = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10"));
+ break;
+ case Empty:
+ pEntry->SetQueryByEmpty();
+ break;
+ case NonEmpty:
+ pEntry->SetQueryByNonEmpty();
+ break;
+ default:
+ // We don't know how to handle this!
+ return;
+ }
}
pViewData->GetView()->Query(aParam, NULL, true);
commit aaad72db3376f236ea49a755c39bac21c53a0704
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 15:51:19 2011 -0500
Execute launching of standard filter dialog.
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index dd5e94f..884d5c6 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -744,6 +744,16 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
if (!pDBData)
return;
+ if (eMode == Custom)
+ {
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ pViewData->GetView()->MarkRange(aRange);
+ pViewData->GetView()->SetCursor(rPos.Col(), rPos.Row());
+ pViewData->GetDispatcher().Execute(SID_FILTER, SFX_CALLMODE_SLOT|SFX_CALLMODE_RECORD);
+ return;
+ }
+
ScQueryParam aParam;
pDBData->GetQueryParam(aParam);
commit 27434041afc8160ed81de83484e00c542e2b859a
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 15:44:18 2011 -0500
We probably don't need to do this for the new popup.
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index e378a7f..dd5e94f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -715,8 +715,6 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup->addMenuItem(
ScResId::toString(ScResId(SCSTR_NOTEMPTY)), true, new AutoFilterAction(this, NonEmpty));
- mpAutoFilterPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
-
mpAutoFilterPopup->launch(aCellRect);
}
commit e2aca79c0186b77e8eb7c4de7a0b35879584fee4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 15:40:12 2011 -0500
Register modes for non-standard autofiltering options.
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 899b973..477536a 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -304,6 +304,8 @@ protected:
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
public:
+ enum AutoFilterMode { Normal, Top10, Custom, Empty, NonEmpty };
+
ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
~ScGridWindow();
@@ -342,7 +344,7 @@ public:
void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
void RefreshAutoFilterButton(const ScAddress& rPos);
- void UpdateAutoFilterFromMenu();
+ void UpdateAutoFilterFromMenu(AutoFilterMode eMode);
void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 4a0d0c9..e378a7f 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -588,28 +588,22 @@ void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSel
namespace {
-class PopupAction : public ScMenuFloatingWindow::Action
-{
-public:
- virtual void execute()
- {
- }
-};
-
struct AutoFilterData : public ScCheckListMenuWindow::ExtendedData
{
ScAddress maPos;
ScDBData* mpData;
};
-class AutoFilterOKAction : public ScMenuFloatingWindow::Action
+class AutoFilterAction : public ScMenuFloatingWindow::Action
{
ScGridWindow* mpWindow;
+ ScGridWindow::AutoFilterMode meMode;
public:
- AutoFilterOKAction(ScGridWindow* p) : mpWindow(p) {}
+ AutoFilterAction(ScGridWindow* p, ScGridWindow::AutoFilterMode eMode) :
+ mpWindow(p), meMode(eMode) {}
virtual void execute()
{
- mpWindow->UpdateAutoFilterFromMenu();
+ mpWindow->UpdateAutoFilterFromMenu(meMode);
}
};
@@ -662,7 +656,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
ScDocument* pDoc = pViewData->GetDocument();
mpAutoFilterPopup.reset(new ScCheckListMenuWindow(this, pDoc));
- mpAutoFilterPopup->setOKAction(new AutoFilterOKAction(this));
+ mpAutoFilterPopup->setOKAction(new AutoFilterAction(this, Normal));
mpAutoFilterPopup->setPopupEndAction(
new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab)));
std::auto_ptr<AutoFilterData> pData(new AutoFilterData);
@@ -712,10 +706,14 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup->initMembers();
// Populate the menu.
- mpAutoFilterPopup->addMenuItem(ScResId::toString(ScResId(SCSTR_TOP10FILTER)), true, new PopupAction);
- mpAutoFilterPopup->addMenuItem(ScResId::toString(ScResId(SCSTR_STDFILTER)), true, new PopupAction);
- mpAutoFilterPopup->addMenuItem(ScResId::toString(ScResId(SCSTR_EMPTY)), true, new PopupAction);
- mpAutoFilterPopup->addMenuItem(ScResId::toString(ScResId(SCSTR_NOTEMPTY)), true, new PopupAction);
+ mpAutoFilterPopup->addMenuItem(
+ ScResId::toString(ScResId(SCSTR_TOP10FILTER)), true, new AutoFilterAction(this, Top10));
+ mpAutoFilterPopup->addMenuItem(
+ ScResId::toString(ScResId(SCSTR_STDFILTER)), true, new AutoFilterAction(this, Custom));
+ mpAutoFilterPopup->addMenuItem(
+ ScResId::toString(ScResId(SCSTR_EMPTY)), true, new AutoFilterAction(this, Empty));
+ mpAutoFilterPopup->addMenuItem(
+ ScResId::toString(ScResId(SCSTR_NOTEMPTY)), true, new AutoFilterAction(this, NonEmpty));
mpAutoFilterPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
@@ -735,7 +733,7 @@ void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
}
}
-void ScGridWindow::UpdateAutoFilterFromMenu()
+void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
{
const AutoFilterData* pData =
static_cast<const AutoFilterData*>(mpAutoFilterPopup->getExtendedData());
commit ab5c5c9d808a5f32d1646de9e1b5cab251b62269
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 15:26:58 2011 -0500
Fix painting of autofilter buttons.
diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx
index ba2e0a3..3835ab9 100644
--- a/sc/source/ui/cctrl/checklistmenu.cxx
+++ b/sc/source/ui/cctrl/checklistmenu.cxx
@@ -104,7 +104,6 @@ ScMenuFloatingWindow::ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, sa
SetFont(maLabelFont);
SetText( OUString(RTL_CONSTASCII_USTRINGPARAM("ScMenuFloatingWindow")) );
- SetPopupModeEndHdl( LINK(this, ScMenuFloatingWindow, PopupEndHdl) );
}
ScMenuFloatingWindow::~ScMenuFloatingWindow()
@@ -112,6 +111,11 @@ ScMenuFloatingWindow::~ScMenuFloatingWindow()
EndPopupMode();
}
+void ScMenuFloatingWindow::PopupModeEnd()
+{
+ handlePopupEnd();
+}
+
void ScMenuFloatingWindow::MouseMove(const MouseEvent& rMEvt)
{
const Point& rPos = rMEvt.GetPosPixel();
@@ -261,6 +265,11 @@ ScMenuFloatingWindow* ScMenuFloatingWindow::addSubMenuItem(const OUString& rText
return aItem.mpSubMenuWin.get();
}
+void ScMenuFloatingWindow::handlePopupEnd()
+{
+ clearSelectedMenuItem();
+}
+
Size ScMenuFloatingWindow::getMenuSize() const
{
if (maMenuItems.empty())
@@ -736,12 +745,6 @@ void ScMenuFloatingWindow::terminateAllPopupMenus()
mpParentMenu->terminateAllPopupMenus();
}
-IMPL_LINK( ScMenuFloatingWindow, PopupEndHdl, void*, EMPTYARG )
-{
- clearSelectedMenuItem();
- return 0;
-}
-
// ============================================================================
ScCheckListMenuWindow::Member::Member() :
@@ -773,6 +776,7 @@ ScCheckListMenuWindow::ScCheckListMenuWindow(Window* pParent, ScDocument* pDoc)
mnCurTabStop(0),
mpExtendedData(NULL),
mpOKAction(NULL),
+ mpPopupEndAction(NULL),
maWndSize(200, 330),
mePrevToggleAllState(STATE_DONTKNOW)
{
@@ -1224,4 +1228,16 @@ void ScCheckListMenuWindow::setOKAction(Action* p)
mpOKAction.reset(p);
}
+void ScCheckListMenuWindow::setPopupEndAction(Action* p)
+{
+ mpPopupEndAction.reset(p);
+}
+
+void ScCheckListMenuWindow::handlePopupEnd()
+{
+ clearSelectedMenuItem();
+ if (mpPopupEndAction)
+ mpPopupEndAction->execute();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 80b180f..34b3be7 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -66,6 +66,7 @@ public:
explicit ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, sal_uInt16 nMenuStackLevel = 0);
virtual ~ScMenuFloatingWindow();
+ virtual void PopupModeEnd();
virtual void MouseMove(const MouseEvent& rMEvt);
virtual void MouseButtonDown(const MouseEvent& rMEvt);
virtual void MouseButtonUp(const MouseEvent& rMEvt);
@@ -90,6 +91,7 @@ public:
ScMenuFloatingWindow* getParentMenuWindow() const;
protected:
+ virtual void handlePopupEnd();
Size getMenuSize() const;
void drawMenuItem(size_t nPos);
@@ -151,8 +153,6 @@ private:
*/
void terminateAllPopupMenus();
- DECL_LINK( PopupEndHdl, void* );
-
private:
struct MenuItemData
@@ -249,6 +249,10 @@ public:
ExtendedData* getExtendedData();
void setOKAction(Action* p);
+ void setPopupEndAction(Action* p);
+
+protected:
+ virtual void handlePopupEnd();
private:
struct Member
@@ -312,6 +316,7 @@ private:
::std::vector<Member> maMembers;
boost::scoped_ptr<ExtendedData> mpExtendedData;
boost::scoped_ptr<Action> mpOKAction;
+ boost::scoped_ptr<Action> mpPopupEndAction;
Size maWndSize; /// whole window size.
Size maMenuSize; /// size of all menu items combined.
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 7793bad..899b973 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -341,6 +341,7 @@ public:
void DoScenarioMenue( const ScRange& rScenRange );
void LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow);
+ void RefreshAutoFilterButton(const ScAddress& rPos);
void UpdateAutoFilterFromMenu();
void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 29d9bd3..4a0d0c9 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -607,13 +607,25 @@ class AutoFilterOKAction : public ScMenuFloatingWindow::Action
ScGridWindow* mpWindow;
public:
AutoFilterOKAction(ScGridWindow* p) : mpWindow(p) {}
-
virtual void execute()
{
mpWindow->UpdateAutoFilterFromMenu();
}
};
+class AutoFilterPopupEndAction : public ScMenuFloatingWindow::Action
+{
+ ScGridWindow* mpWindow;
+ ScAddress maPos;
+public:
+ AutoFilterPopupEndAction(ScGridWindow* p, const ScAddress& rPos) :
+ mpWindow(p), maPos(rPos) {}
+ virtual void execute()
+ {
+ mpWindow->RefreshAutoFilterButton(maPos);
+ }
+};
+
class AddItemToEntry : public std::unary_function<rtl::OUString, void>
{
ScQueryEntry::QueryItemsType& mrItems;
@@ -651,6 +663,8 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup.reset(new ScCheckListMenuWindow(this, pDoc));
mpAutoFilterPopup->setOKAction(new AutoFilterOKAction(this));
+ mpAutoFilterPopup->setPopupEndAction(
+ new AutoFilterPopupEndAction(this, ScAddress(nCol, nRow, nTab)));
std::auto_ptr<AutoFilterData> pData(new AutoFilterData);
pData->maPos = ScAddress(nCol, nRow, nTab);
@@ -708,6 +722,19 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup->launch(aCellRect);
}
+void ScGridWindow::RefreshAutoFilterButton(const ScAddress& rPos)
+{
+ if (mpFilterButton)
+ {
+ bool bFilterActive = IsAutoFilterActive(rPos.Col(), rPos.Row(), rPos.Tab());
+ mpFilterButton->setHasHiddenMember(bFilterActive);
+ mpFilterButton->setPopupPressed(false);
+ HideCursor();
+ mpFilterButton->draw();
+ ShowCursor();
+ }
+}
+
void ScGridWindow::UpdateAutoFilterFromMenu()
{
const AutoFilterData* pData =
@@ -1980,20 +2007,6 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
if (nMouseStatus == SC_GM_FILTER)
{
- if ( pFilterBox && pFilterBox->GetMode() == SC_FILTERBOX_FILTER )
- {
- if (mpFilterButton)
- {
- bool bFilterActive = IsAutoFilterActive(
- pFilterBox->GetCol(), pFilterBox->GetRow(), pViewData->GetTabNo() );
-
- mpFilterButton->setHasHiddenMember(bFilterActive);
- mpFilterButton->setPopupPressed(false);
- HideCursor();
- mpFilterButton->draw();
- ShowCursor();
- }
- }
nMouseStatus = SC_GM_NONE;
ReleaseMouse();
return; // da muss nix mehr passieren
@@ -2433,17 +2446,6 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt )
{
nButtonDown = 0;
nMouseStatus = SC_GM_NONE;
- if ( pFilterBox->GetMode() == SC_FILTERBOX_FILTER )
- {
- if (mpFilterButton)
- {
- mpFilterButton->setHasHiddenMember(false);
- mpFilterButton->setPopupPressed(false);
- HideCursor();
- mpFilterButton->draw();
- ShowCursor();
- }
- }
ReleaseMouse();
pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) );
return;
commit de171082fc55fd52e35a0d0528d47c1ff89191f9
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Nov 18 14:37:47 2011 -0500
Use scoped_ptr instead of auto_ptr; auto_ptr is deprecated.
diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx
index 8f402d0..80b180f 100644
--- a/sc/source/ui/inc/checklistmenu.hxx
+++ b/sc/source/ui/inc/checklistmenu.hxx
@@ -35,8 +35,8 @@
#include "vcl/timer.hxx"
#include "svx/checklbx.hxx"
-#include <memory>
#include <boost/unordered_map.hpp>
+#include <boost/scoped_ptr.hpp>
namespace com { namespace sun { namespace star {
@@ -310,8 +310,8 @@ private:
size_t mnCurTabStop;
::std::vector<Member> maMembers;
- ::std::auto_ptr<ExtendedData> mpExtendedData;
- ::std::auto_ptr<Action> mpOKAction;
+ boost::scoped_ptr<ExtendedData> mpExtendedData;
+ boost::scoped_ptr<Action> mpOKAction;
Size maWndSize; /// whole window size.
Size maMenuSize; /// size of all menu items combined.
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 6105ae3..29d9bd3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -704,6 +704,7 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
mpAutoFilterPopup->addMenuItem(ScResId::toString(ScResId(SCSTR_NOTEMPTY)), true, new PopupAction);
mpAutoFilterPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
+
mpAutoFilterPopup->launch(aCellRect);
}
More information about the Libreoffice-commits
mailing list