[Libreoffice-commits] core.git: 2 commits - include/sfx2 sfx2/source sfx2/uiconfig
Krisztian Pinter
pin.terminator at gmail.com
Fri Aug 16 09:09:09 PDT 2013
include/sfx2/recentdocsview.hxx | 27 ++++----
sfx2/source/control/recentdocsview.cxx | 67 +++++++++++---------
sfx2/source/dialog/backingwindow.cxx | 108 ++++++++++++++++++---------------
sfx2/source/dialog/backingwindow.hxx | 14 ++--
sfx2/uiconfig/ui/startcenter.ui | 16 ++--
5 files changed, 126 insertions(+), 106 deletions(-)
New commits:
commit 454ff1a48ed21a8bff8373a1aa7707e286629e9a
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date: Tue Aug 13 17:56:46 2013 +0200
startcenter: Disable tabs for modules not installed
Change-Id: I74dbd1dab44efa87a78ad3268658895f2d1542db
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index cda286e..2e8afdf 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -70,21 +70,22 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
"sfx/ui/startcenter.ui",
"StartCenter" );
- get(mpOpenButton, "open");
- get(mpTemplateButton, "templates");
+ get(mpOpenButton, "open");
+ get(mpTemplateButton, "templates");
- get(mpWriterButton, "writer");
- get(mpCalcButton, "calc");
- get(mpImpressButton, "impress");
- get(mpDrawButton, "draw");
- get(mpDBButton, "database");
- get(mpMathButton, "math");
+ get(mpModuleNotebook, "modules_notebook");
+
+ get(mpWriterButton, "writer");
+ get(mpCalcButton, "calc");
+ get(mpImpressButton, "impress");
+ get(mpDrawButton, "draw");
+ get(mpDBButton, "database");
+ get(mpMathButton, "math");
get(mpExtensionsButton, "extension");
get(mpInfoButton, "info");
get(mpTplRepButton, "add_temp");
-
get( mpAllRecentThumbnails, "all_recent");
get( mpWriterRecentThumbnails, "writer_recent");
get( mpCalcRecentThumbnails, "calc_recent");
@@ -93,23 +94,6 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get( mpDatabaseRecentThumbnails, "database_recent");
get( mpMathRecentThumbnails, "math_recent");
- mpAllRecentThumbnails ->addFileType(TYPE_WRITER | TYPE_CALC |
- TYPE_IMPRESS | TYPE_DRAW | TYPE_DATABASE | TYPE_MATH | TYPE_OTHER);
- mpWriterRecentThumbnails ->addFileType(TYPE_WRITER);
- mpCalcRecentThumbnails ->addFileType(TYPE_CALC);
- mpImpressRecentThumbnails ->addFileType(TYPE_IMPRESS);
- mpDrawRecentThumbnails ->addFileType(TYPE_DRAW);
- mpDatabaseRecentThumbnails ->addFileType(TYPE_DATABASE);
- mpMathRecentThumbnails ->addFileType(TYPE_MATH);
-
- mpAllRecentThumbnails ->loadRecentDocs();
- mpWriterRecentThumbnails ->loadRecentDocs();
- mpCalcRecentThumbnails ->loadRecentDocs();
- mpImpressRecentThumbnails ->loadRecentDocs();
- mpDrawRecentThumbnails ->loadRecentDocs();
- mpDatabaseRecentThumbnails ->loadRecentDocs();
- mpMathRecentThumbnails ->loadRecentDocs();
-
try
{
mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
@@ -211,23 +195,39 @@ void BackingWindow::initControls()
aFileNewAppsAvailable.insert( sURL );
}
- setupButton( mpWriterButton, WRITER_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SWRITER );
- setupButton( mpDrawButton, DRAW_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SDRAW );
- setupButton( mpCalcButton, CALC_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SCALC );
- setupButton( mpDBButton, BASE_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SDATABASE );
- setupButton( mpImpressButton, IMPRESS_WIZARD_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SIMPRESS );
- setupButton( mpMathButton, MATH_URL, aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SMATH );
-
- setupButton( mpOpenButton, "", aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SWRITER );
- setupButton( mpTemplateButton, "", aFileNewAppsAvailable,
- aModuleOptions, SvtModuleOptions::E_SWRITER );
+ setupModuleTab( "tab_writer", mpWriterRecentThumbnails, TYPE_WRITER,
+ WRITER_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SWRITER );
+ setupModuleTab( "tab_calc", mpCalcRecentThumbnails, TYPE_CALC,
+ DRAW_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SDRAW );
+ setupModuleTab( "tab_impress", mpImpressRecentThumbnails, TYPE_IMPRESS,
+ CALC_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SCALC );
+ setupModuleTab( "tab_draw", mpDrawRecentThumbnails, TYPE_DRAW,
+ BASE_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SDATABASE );
+ setupModuleTab( "tab_database", mpDatabaseRecentThumbnails, TYPE_DATABASE,
+ IMPRESS_WIZARD_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SIMPRESS );
+ setupModuleTab( "tab_math", mpMathRecentThumbnails, TYPE_MATH,
+ MATH_URL, aFileNewAppsAvailable, aModuleOptions,
+ SvtModuleOptions::E_SMATH );
+
+ // File types for mpAllRecentThumbnails are added in the above calls
+ // of setupModuleTab. TYPE_OTHER is always added.
+ mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
+ mpAllRecentThumbnails->loadRecentDocs();
+
+ setupButton( mpWriterButton );
+ setupButton( mpDrawButton );
+ setupButton( mpCalcButton );
+ setupButton( mpDBButton );
+ setupButton( mpImpressButton );
+ setupButton( mpMathButton );
+
+ setupButton( mpOpenButton );
+ setupButton( mpTemplateButton );
setupExternalLink( mpExtensionsButton );
setupExternalLink( mpInfoButton );
@@ -238,17 +238,27 @@ void BackingWindow::initControls()
mpWriterButton->GrabFocus();
}
-void BackingWindow::setupButton( PushButton* pButton, const OUString &rURL,
- const std::set<OUString>& rURLS,
- SvtModuleOptions& rOpt, SvtModuleOptions::EModule eMod )
+void BackingWindow::setupModuleTab(const OString& rTabName, RecentDocsView* pRecView, int nFileTypes,
+ const OUString &rURL, const std::set<OUString>& rURLS, SvtModuleOptions& rOpt,
+ SvtModuleOptions::EModule eMod)
{
- pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
-
- // disable the parts that are not installed
if( !rURL.isEmpty() && (!rOpt.IsModuleInstalled( eMod ) || rURLS.find( rURL ) == rURLS.end()) )
{
- pButton->Enable( sal_False );
+ // disable the parts that are not installed
+ mpModuleNotebook->RemovePage( mpModuleNotebook->GetPageId(rTabName) );
+ }
+ else
+ {
+ // if a module is installed, add that filetype to the "All" page
+ mpAllRecentThumbnails-> mnFileTypes |= nFileTypes;
+ pRecView->mnFileTypes |= nFileTypes;
+ pRecView->loadRecentDocs();
}
+}
+
+void BackingWindow::setupButton( PushButton* pButton )
+{
+ pButton->SetClickHdl( LINK( this, BackingWindow, ClickHdl ) );
// setup text - slighly larger font than normal labels on the texts
Font aFont;
diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx
index 99ba9e1..7fbcabd 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -24,6 +24,7 @@
#include <vcl/builder.hxx>
#include <vcl/button.hxx>
+#include <vcl/tabctrl.hxx>
#include <vcl/layout.hxx>
#include <sfx2/recentdocsview.hxx>
@@ -49,6 +50,8 @@ class BackingWindow
PushButton* mpOpenButton;
PushButton* mpTemplateButton;
+ TabControl* mpModuleNotebook;
+
PushButton* mpWriterButton;
PushButton* mpCalcButton;
PushButton* mpImpressButton;
@@ -68,19 +71,16 @@ class BackingWindow
RecentDocsView* mpDatabaseRecentThumbnails;
RecentDocsView* mpMathRecentThumbnails;
- BitmapEx maBackgroundLeft;
- BitmapEx maBackgroundMiddle;
- BitmapEx maBackgroundRight;
-
Rectangle maStartCentButtons;
bool mbInitControls;
sal_Int32 mnHideExternalLinks;
svt::AcceleratorExecute* mpAccExec;
- void setupButton( PushButton* pButton, const OUString& rURL, const std::set<OUString>& rURLS,
- SvtModuleOptions& rOpt, SvtModuleOptions::EModule eMod );
-
+ void setupModuleTab( const OString& rTabName, RecentDocsView* pRecView, int nFileTypes,
+ const OUString& rURL, const std::set<OUString>& rURLS, SvtModuleOptions& rOpt,
+ SvtModuleOptions::EModule eMod );
+ void setupButton( PushButton* pButton );
void setupExternalLink( PushButton* pButton );
void dispatchURL( const OUString& i_rURL,
diff --git a/sfx2/uiconfig/ui/startcenter.ui b/sfx2/uiconfig/ui/startcenter.ui
index 279377f..05d4bdb 100644
--- a/sfx2/uiconfig/ui/startcenter.ui
+++ b/sfx2/uiconfig/ui/startcenter.ui
@@ -44,7 +44,7 @@
<property name="row_spacing">12</property>
<property name="column_spacing">12</property>
<child>
- <object class="GtkNotebook" id="notebook1">
+ <object class="GtkNotebook" id="modules_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@@ -87,7 +87,7 @@
</object>
</child>
<child type="tab">
- <object class="GtkLabel" id="label1">
+ <object class="GtkLabel" id="tab_all">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">All Recent</property>
@@ -150,7 +150,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label2">
+ <object class="GtkLabel" id="tab_writer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Documents</property>
@@ -214,7 +214,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label3">
+ <object class="GtkLabel" id="tab_calc">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Spreadsheets</property>
@@ -278,7 +278,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label4">
+ <object class="GtkLabel" id="tab_impress">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Presentations</property>
@@ -342,7 +342,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label5">
+ <object class="GtkLabel" id="tab_draw">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Drawings</property>
@@ -406,7 +406,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label6">
+ <object class="GtkLabel" id="tab_database">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Databases</property>
@@ -470,7 +470,7 @@
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label7">
+ <object class="GtkLabel" id="tab_math">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Formulas</property>
commit c09a301dbe80951ed94119f4cd14943e99df42eb
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date: Tue Aug 13 21:29:33 2013 +0200
startcenter: Improve file type filtering in RecentDocsView
Change-Id: Iac53a50e4c66963279016bd0178de9f43bd146e3
diff --git a/include/sfx2/recentdocsview.hxx b/include/sfx2/recentdocsview.hxx
index 9cb77d3..ebb915c 100644
--- a/include/sfx2/recentdocsview.hxx
+++ b/include/sfx2/recentdocsview.hxx
@@ -24,17 +24,19 @@ struct LoadRecentFile
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
};
-enum APPLICATION_FILTER
+enum ApplicationType
{
- FILTER_NONE,
- FILTER_WRITER,
- FILTER_CALC,
- FILTER_IMPRESS,
- FILTER_DRAW,
- FILTER_DATABASE,
- FILTER_MATH,
+ TYPE_NONE = 0,
+ TYPE_WRITER = 1 << 0,
+ TYPE_CALC = 1 << 1,
+ TYPE_IMPRESS = 1 << 2,
+ TYPE_DRAW = 1 << 3,
+ TYPE_DATABASE = 1 << 4,
+ TYPE_MATH = 1 << 5,
+ TYPE_OTHER = 1 << 6
};
+
class SFX2_DLLPUBLIC RecentDocsView : protected ::comphelper::OBaseMutex,
public ThumbnailView
{
@@ -47,19 +49,18 @@ public:
void SetThumbnailSize(long thumbnailSize);
long GetThumbnailSize() const;
- void SetFilter(APPLICATION_FILTER filter);
- static bool isFilteredExtension(APPLICATION_FILTER filter, const OUString &rExt);
+ static bool typeMatchesExtension(ApplicationType type, const OUString &rExt);
static BitmapEx getDefaultThumbnail(const OUString &rURL);
+ int mnFileTypes;
+
DECL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, LoadRecentFile* );
protected:
virtual void OnItemDblClicked(ThumbnailViewItem *pItem);
- bool isUnfilteredFile(const OUString &rURL) const;
-
- APPLICATION_FILTER mFilter;
+ bool isAcceptedFile(const OUString &rURL) const;
long mnItemMaxSize;
long mnTextHeight;
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index a532b14..1099911 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -41,6 +41,7 @@ static const char SFX_REFERER_USER[] = "private:user";
RecentDocsView::RecentDocsView( Window* pParent )
: ThumbnailView(pParent)
+ , mnFileTypes(TYPE_NONE)
, mnItemMaxSize(100)
, mnTextHeight(30)
, mnItemPadding(5)
@@ -60,44 +61,55 @@ RecentDocsView::~RecentDocsView()
{
}
-bool RecentDocsView::isFilteredExtension(APPLICATION_FILTER filter, const OUString &rExt)
+bool RecentDocsView::typeMatchesExtension(ApplicationType type, const OUString &rExt)
{
- bool bRet = true;
+ bool bRet = false;
- if (filter == FILTER_WRITER)
+ if (rExt == "odt" || rExt == "doc" || rExt == "docx" ||
+ rExt == "rtf" || rExt == "txt")
{
- bRet = rExt == "odt" || rExt == "doc" || rExt == "docx" ||
- rExt == "rtf" || rExt == "txt";
+ bRet = type & TYPE_WRITER;
}
- else if (filter == FILTER_CALC)
+ else if (rExt == "ods" || rExt == "xls" || rExt == "xlsx")
{
- bRet = rExt == "ods" || rExt == "xls" || rExt == "xlsx";
+ bRet = type & TYPE_CALC;
}
- else if (filter == FILTER_IMPRESS)
+ else if (rExt == "odp" || rExt == "pps" || rExt == "ppt" ||
+ rExt == "pptx")
{
- bRet = rExt == "odp" || rExt == "pps" || rExt == "ppt" ||
- rExt == "pptx";
+ bRet = type & TYPE_IMPRESS;
}
- else if (filter == FILTER_DRAW)
+ else if (rExt == "odg")
{
- bRet = rExt == "odg";
+ bRet = type & TYPE_DRAW;
}
- else if (filter == FILTER_DATABASE)
+ else if (rExt == "odb")
{
- bRet = rExt == "odb";
+ bRet = type & TYPE_DATABASE;
}
- else if (filter == FILTER_MATH)
+ else if (rExt == "odf")
{
- bRet = rExt == "odf";
+ bRet = type & TYPE_MATH;
+ }
+ else
+ {
+ bRet = type & TYPE_OTHER;
}
return bRet;
}
-bool RecentDocsView::isUnfilteredFile(const OUString &rURL) const
+bool RecentDocsView::isAcceptedFile(const OUString &rURL) const
{
INetURLObject aUrl(rURL);
- return isFilteredExtension(mFilter, aUrl.getExtension());
+ OUString aExt = aUrl.getExtension();
+ return (mnFileTypes & TYPE_WRITER && typeMatchesExtension(TYPE_WRITER, aExt)) ||
+ (mnFileTypes & TYPE_CALC && typeMatchesExtension(TYPE_CALC, aExt)) ||
+ (mnFileTypes & TYPE_IMPRESS && typeMatchesExtension(TYPE_IMPRESS, aExt)) ||
+ (mnFileTypes & TYPE_DRAW && typeMatchesExtension(TYPE_DRAW, aExt)) ||
+ (mnFileTypes & TYPE_DATABASE && typeMatchesExtension(TYPE_DATABASE,aExt)) ||
+ (mnFileTypes & TYPE_MATH && typeMatchesExtension(TYPE_MATH, aExt)) ||
+ (mnFileTypes & TYPE_OTHER && typeMatchesExtension(TYPE_OTHER, aExt));
}
BitmapEx RecentDocsView::getDefaultThumbnail(const OUString &rURL)
@@ -106,17 +118,17 @@ BitmapEx RecentDocsView::getDefaultThumbnail(const OUString &rURL)
INetURLObject aUrl(rURL);
OUString aExt = aUrl.getExtension();
- if ( isFilteredExtension( FILTER_WRITER, aExt) )
+ if ( typeMatchesExtension( TYPE_WRITER, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_TEXT ) );
- else if ( isFilteredExtension( FILTER_CALC, aExt) )
+ else if ( typeMatchesExtension( TYPE_CALC, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_SHEET ) );
- else if ( isFilteredExtension( FILTER_IMPRESS, aExt) )
+ else if ( typeMatchesExtension( TYPE_IMPRESS, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_PRESENTATION ) );
- else if ( isFilteredExtension( FILTER_DRAW, aExt) )
+ else if ( typeMatchesExtension( TYPE_DRAW, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DRAWING ) );
- else if ( isFilteredExtension( FILTER_DATABASE, aExt) )
+ else if ( typeMatchesExtension( TYPE_DATABASE, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DATABASE ) );
- else if ( isFilteredExtension( FILTER_MATH, aExt) )
+ else if ( typeMatchesExtension( TYPE_MATH, aExt) )
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_MATH ) );
else
aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DEFAULT ) );
@@ -153,7 +165,7 @@ void RecentDocsView::loadRecentDocs()
a >>= aTitle;
}
- if( isUnfilteredFile(aURL) )
+ if( isAcceptedFile(aURL) )
{
insertItem(aURL, aTitle);
}
@@ -221,11 +233,6 @@ long RecentDocsView::GetThumbnailSize() const
return mnItemMaxSize;
}
-void RecentDocsView::SetFilter(APPLICATION_FILTER filter)
-{
- mFilter = filter;
-}
-
IMPL_STATIC_LINK_NOINSTANCE( RecentDocsView, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile )
{
try
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index 61573a8..cda286e 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -93,12 +93,14 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get( mpDatabaseRecentThumbnails, "database_recent");
get( mpMathRecentThumbnails, "math_recent");
- mpWriterRecentThumbnails ->SetFilter(FILTER_WRITER);
- mpCalcRecentThumbnails ->SetFilter(FILTER_CALC);
- mpImpressRecentThumbnails ->SetFilter(FILTER_IMPRESS);
- mpDrawRecentThumbnails ->SetFilter(FILTER_DRAW);
- mpDatabaseRecentThumbnails ->SetFilter(FILTER_DATABASE);
- mpMathRecentThumbnails ->SetFilter(FILTER_MATH);
+ mpAllRecentThumbnails ->addFileType(TYPE_WRITER | TYPE_CALC |
+ TYPE_IMPRESS | TYPE_DRAW | TYPE_DATABASE | TYPE_MATH | TYPE_OTHER);
+ mpWriterRecentThumbnails ->addFileType(TYPE_WRITER);
+ mpCalcRecentThumbnails ->addFileType(TYPE_CALC);
+ mpImpressRecentThumbnails ->addFileType(TYPE_IMPRESS);
+ mpDrawRecentThumbnails ->addFileType(TYPE_DRAW);
+ mpDatabaseRecentThumbnails ->addFileType(TYPE_DATABASE);
+ mpMathRecentThumbnails ->addFileType(TYPE_MATH);
mpAllRecentThumbnails ->loadRecentDocs();
mpWriterRecentThumbnails ->loadRecentDocs();
More information about the Libreoffice-commits
mailing list