Kaydet (Commit) f8426f50 authored tarafından Krisztian Pinter's avatar Krisztian Pinter Kaydeden (comit) Jan Holesovsky

startcenter: Add toggle to view templates in Start Center

Change-Id: I17aa3bfbb7f4b0eca525dd15d6866c6951d5d20f
Reviewed-on: https://gerrit.libreoffice.org/5543Reviewed-by: 's avatarJan Holesovsky <kendy@suse.cz>
Tested-by: 's avatarJan Holesovsky <kendy@suse.cz>
üst 40ff64b9
...@@ -482,6 +482,9 @@ ...@@ -482,6 +482,9 @@
<glade-widget-class title="Recent Documents View" name="sfxlo-RecentDocsView" <glade-widget-class title="Recent Documents View" name="sfxlo-RecentDocsView"
generic-name="Icon View" parent="GtkIconView" generic-name="Icon View" parent="GtkIconView"
icon-name="widget-gtk-iconview"/> icon-name="widget-gtk-iconview"/>
<glade-widget-class title="Template Thumbnail View" name="sfxlo-TemplateLocalView"
generic-name="Template Icon View" parent="GtkIconView"
icon-name="widget-gtk-iconview"/>
</glade-widget-classes> </glade-widget-classes>
</glade-catalog> </glade-catalog>
...@@ -81,8 +81,8 @@ class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView ...@@ -81,8 +81,8 @@ class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
public: public:
TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren); TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
TemplateAbstractView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false ); TemplateAbstractView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
TemplateAbstractView ( Window* pParent );
virtual ~TemplateAbstractView (); virtual ~TemplateAbstractView ();
......
...@@ -30,6 +30,7 @@ class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView ...@@ -30,6 +30,7 @@ class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView
public: public:
TemplateLocalView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false ); TemplateLocalView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
TemplateLocalView ( Window* pParent );
virtual ~TemplateLocalView (); virtual ~TemplateLocalView ();
......
...@@ -142,6 +142,18 @@ TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId, ...@@ -142,6 +142,18 @@ TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId,
maFTName.Hide(); maFTName.Hide();
} }
TemplateAbstractView::TemplateAbstractView(Window *pParent)
: ThumbnailView(pParent),
mnCurRegionId(0),
maAllButton(this, SfxResId(BTN_ALL_TEMPLATES)),
maFTName(this, SfxResId(FT_NAME))
{
maAllButton.Hide();
maAllButton.SetStyle(maAllButton.GetStyle() | WB_FLATBUTTON);
maAllButton.SetClickHdl(LINK(this,TemplateAbstractView,ShowRootRegionHdl));
maFTName.Hide();
}
TemplateAbstractView::~TemplateAbstractView () TemplateAbstractView::~TemplateAbstractView ()
{ {
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <svl/inettype.hxx> #include <svl/inettype.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
#include <vcl/builder.hxx>
#include <vcl/pngread.hxx> #include <vcl/pngread.hxx>
#include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/ElementModes.hpp>
...@@ -37,6 +38,17 @@ TemplateLocalView::TemplateLocalView ( Window* pParent, const ResId& rResId, boo ...@@ -37,6 +38,17 @@ TemplateLocalView::TemplateLocalView ( Window* pParent, const ResId& rResId, boo
{ {
} }
TemplateLocalView::TemplateLocalView ( Window* pParent)
: TemplateAbstractView(pParent),
mpDocTemplates(new SfxDocumentTemplates)
{
}
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeTemplateLocalView(Window *pParent, VclBuilder::stringmap &)
{
return new TemplateLocalView(pParent);
}
TemplateLocalView::~TemplateLocalView() TemplateLocalView::~TemplateLocalView()
{ {
for (size_t i = 0; i < maRegions.size(); ++i) for (size_t i = 0; i < maRegions.size(); ++i)
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <toolkit/awt/vclxmenu.hxx> #include <toolkit/awt/vclxmenu.hxx>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/document/UpdateDocMode.hpp>
#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
...@@ -38,11 +40,13 @@ ...@@ -38,11 +40,13 @@
#include <com/sun/star/system/SystemShellExecute.hpp> #include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.hpp> #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
#include <com/sun/star/util/URLTransformer.hpp> #include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans; using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star; using namespace ::com::sun::star::document;
const char RECENT_FILE_LIST[] = ".uno:RecentFileList"; const char RECENT_FILE_LIST[] = ".uno:RecentFileList";
...@@ -60,8 +64,15 @@ const int nItemId_Extensions = 1; ...@@ -60,8 +64,15 @@ const int nItemId_Extensions = 1;
const int nItemId_Info = 3; const int nItemId_Info = 3;
const int nItemId_TplRep = 4; const int nItemId_TplRep = 4;
const int nTemplateItemMaxWidth = 160;
const int nTemplateItemMaxHeight = 148;
const int nTemplateItemPadding = 5;
const int nTemplateItemMaxTextLength = 20;
const int nTemplateItemThumbnailMaxHeight = 96;
BackingWindow::BackingWindow( Window* i_pParent ) : BackingWindow::BackingWindow( Window* i_pParent ) :
Window( i_pParent ), Window( i_pParent ),
mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
mbInitControls( false ), mbInitControls( false ),
mnHideExternalLinks( 0 ), mnHideExternalLinks( 0 ),
mpAccExec( NULL ) mpAccExec( NULL )
...@@ -93,6 +104,16 @@ BackingWindow::BackingWindow( Window* i_pParent ) : ...@@ -93,6 +104,16 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get(mpInfoButton, "info"); get(mpInfoButton, "info");
get(mpTplRepButton, "add_temp"); get(mpTplRepButton, "add_temp");
get(mpShowWriterTemplateButton, "show_writer_template");
get(mpShowCalcTemplateButton, "show_calc_template");
get(mpShowImpressTemplateButton, "show_impress_template");
get(mpShowDrawTemplateButton, "show_draw_template");
get(mpShowWriterRecentButton, "show_writer_recent");
get(mpShowCalcRecentButton, "show_calc_recent");
get(mpShowImpressRecentButton, "show_impress_recent");
get(mpShowDrawRecentButton, "show_draw_recent");
get( mpAllRecentThumbnails, "all_recent"); get( mpAllRecentThumbnails, "all_recent");
get( mpWriterRecentThumbnails, "writer_recent"); get( mpWriterRecentThumbnails, "writer_recent");
get( mpCalcRecentThumbnails, "calc_recent"); get( mpCalcRecentThumbnails, "calc_recent");
...@@ -101,6 +122,11 @@ BackingWindow::BackingWindow( Window* i_pParent ) : ...@@ -101,6 +122,11 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get( mpDatabaseRecentThumbnails, "database_recent"); get( mpDatabaseRecentThumbnails, "database_recent");
get( mpMathRecentThumbnails, "math_recent"); get( mpMathRecentThumbnails, "math_recent");
get( mpWriterTemplateThumbnails, "writer_templates");
get( mpCalcTemplateThumbnails, "calc_templates");
get( mpImpressTemplateThumbnails, "impress_templates");
get( mpDrawTemplateThumbnails, "draw_templates");
try try
{ {
mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW ); mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
...@@ -158,6 +184,10 @@ BackingWindow::BackingWindow( Window* i_pParent ) : ...@@ -158,6 +184,10 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
BackingWindow::~BackingWindow() BackingWindow::~BackingWindow()
{ {
mpWriterTemplateThumbnails ->setOpenTemplateHdl(Link());
mpCalcTemplateThumbnails ->setOpenTemplateHdl(Link());
mpImpressTemplateThumbnails ->setOpenTemplateHdl(Link());
mpDrawTemplateThumbnails ->setOpenTemplateHdl(Link());
} }
IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent ) IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent )
...@@ -247,6 +277,26 @@ void BackingWindow::initControls() ...@@ -247,6 +277,26 @@ void BackingWindow::initControls()
setupExternalLink( mpInfoButton ); setupExternalLink( mpInfoButton );
setupExternalLink( mpTplRepButton ); setupExternalLink( mpTplRepButton );
mpShowWriterTemplateButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowCalcTemplateButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowImpressTemplateButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowDrawTemplateButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowWriterRecentButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowCalcRecentButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowImpressRecentButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowDrawRecentButton ->SetClickHdl( LINK( this, BackingWindow, RecentTemplateToggleHdl ) );
mpShowWriterRecentButton ->Hide();
mpShowCalcRecentButton ->Hide();
mpShowImpressRecentButton ->Hide();
mpShowDrawRecentButton ->Hide();
setupTemplateView( mpWriterTemplateThumbnails, FILTER_APP_WRITER );
setupTemplateView( mpCalcTemplateThumbnails, FILTER_APP_CALC );
setupTemplateView( mpImpressTemplateThumbnails, FILTER_APP_IMPRESS );
setupTemplateView( mpDrawTemplateThumbnails, FILTER_APP_DRAW );
Resize(); Resize();
} }
...@@ -281,6 +331,20 @@ void BackingWindow::setupButton( PushButton* pButton ) ...@@ -281,6 +331,20 @@ void BackingWindow::setupButton( PushButton* pButton )
pButton->SetControlFont( aFont ); pButton->SetControlFont( aFont );
} }
void BackingWindow::setupTemplateView( TemplateLocalView* pView, FILTER_APPLICATION eFilter )
{
pView->SetStyle(pView->GetStyle() | WB_VSCROLL);
pView->setItemMaxTextLength(nTemplateItemMaxTextLength);
pView->setItemDimensions(nTemplateItemMaxWidth, nTemplateItemThumbnailMaxHeight,
nTemplateItemMaxHeight-nTemplateItemMaxHeight, nTemplateItemPadding);
pView->filterItems(ViewFilter_Application(eFilter));
pView->Populate();
pView->Hide(); // hidden by default
pView->showRootRegion();
pView->setOpenTemplateHdl( LINK( this, BackingWindow, OpenTemplateHdl ) );
}
void BackingWindow::setupExternalLink( PushButton* pButton ) void BackingWindow::setupExternalLink( PushButton* pButton )
{ {
if( mnHideExternalLinks == 0 ) if( mnHideExternalLinks == 0 )
...@@ -441,6 +505,96 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton ) ...@@ -441,6 +505,96 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
return 0; return 0;
} }
IMPL_LINK( BackingWindow, RecentTemplateToggleHdl, Button*, pButton )
{
// writer
if( pButton == mpShowWriterTemplateButton )
{
mpWriterRecentThumbnails->Hide();
mpWriterTemplateThumbnails->Show();
mpShowWriterTemplateButton->Hide();
mpShowWriterRecentButton->Show();
}
else if( pButton == mpShowWriterRecentButton )
{
mpWriterRecentThumbnails->Show();
mpWriterTemplateThumbnails->Hide();
mpShowWriterTemplateButton->Show();
mpShowWriterRecentButton->Hide();
}
// calc
else if( pButton == mpShowCalcTemplateButton )
{
mpCalcRecentThumbnails->Hide();
mpCalcTemplateThumbnails->Show();
mpShowCalcTemplateButton->Hide();
mpShowCalcRecentButton->Show();
}
else if( pButton == mpShowCalcRecentButton )
{
mpCalcRecentThumbnails->Show();
mpCalcTemplateThumbnails->Hide();
mpShowCalcTemplateButton->Show();
mpShowCalcRecentButton->Hide();
}
// impress
else if( pButton == mpShowImpressTemplateButton )
{
mpImpressRecentThumbnails->Hide();
mpImpressTemplateThumbnails->Show();
mpShowImpressTemplateButton->Hide();
mpShowImpressRecentButton->Show();
}
else if( pButton == mpShowImpressRecentButton )
{
mpImpressRecentThumbnails->Show();
mpImpressTemplateThumbnails->Hide();
mpShowImpressTemplateButton->Show();
mpShowImpressRecentButton->Hide();
}
// draw
else if( pButton == mpShowDrawTemplateButton )
{
mpDrawRecentThumbnails->Hide();
mpDrawTemplateThumbnails->Show();
mpShowDrawTemplateButton->Hide();
mpShowDrawRecentButton->Show();
}
else if( pButton == mpShowDrawRecentButton )
{
mpDrawRecentThumbnails->Show();
mpDrawTemplateThumbnails->Hide();
mpShowDrawTemplateButton->Show();
mpShowDrawRecentButton->Hide();
}
return 0;
}
IMPL_LINK( BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem)
{
uno::Sequence< PropertyValue > aArgs(4);
aArgs[0].Name = "AsTemplate";
aArgs[0].Value <<= sal_True;
aArgs[1].Name = "MacroExecutionMode";
aArgs[1].Value <<= MacroExecMode::USE_CONFIG;
aArgs[2].Name = "UpdateDocMode";
aArgs[2].Value <<= UpdateDocMode::ACCORDING_TO_CONFIG;
aArgs[3].Name = "InteractionHandler";
aArgs[3].Value <<= task::InteractionHandler::createWithParent( ::comphelper::getProcessComponentContext(), 0 );
TemplateViewItem *pTemplateItem = static_cast<TemplateViewItem*>(pItem);
try
{
mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs );
}
catch( const uno::Exception& )
{
}
return 0;
}
struct ImplDelayedDispatch struct ImplDelayedDispatch
{ {
Reference< XDispatch > xDispatch; Reference< XDispatch > xDispatch;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <sfx2/recentdocsview.hxx> #include <sfx2/recentdocsview.hxx>
#include <sfx2/templatelocalview.hxx>
#include <sfx2/templateviewitem.hxx>
#include <svtools/acceleratorexecute.hxx> #include <svtools/acceleratorexecute.hxx>
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
...@@ -36,6 +38,7 @@ ...@@ -36,6 +38,7 @@
#include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDesktop2.hpp>
#include <set> #include <set>
...@@ -46,6 +49,7 @@ class BackingWindow ...@@ -46,6 +49,7 @@ class BackingWindow
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext; com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider > mxDesktopDispatchProvider; com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider > mxDesktopDispatchProvider;
com::sun::star::uno::Reference<com::sun::star::frame::XFrame> mxFrame; com::sun::star::uno::Reference<com::sun::star::frame::XFrame> mxFrame;
com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2 > mxDesktop;
PushButton* mpOpenButton; PushButton* mpOpenButton;
PushButton* mpTemplateButton; PushButton* mpTemplateButton;
...@@ -70,6 +74,16 @@ class BackingWindow ...@@ -70,6 +74,16 @@ class BackingWindow
PushButton* mpInfoButton; PushButton* mpInfoButton;
PushButton* mpTplRepButton; PushButton* mpTplRepButton;
PushButton* mpShowWriterTemplateButton;
PushButton* mpShowCalcTemplateButton;
PushButton* mpShowImpressTemplateButton;
PushButton* mpShowDrawTemplateButton;
PushButton* mpShowWriterRecentButton;
PushButton* mpShowCalcRecentButton;
PushButton* mpShowImpressRecentButton;
PushButton* mpShowDrawRecentButton;
RecentDocsView* mpAllRecentThumbnails; RecentDocsView* mpAllRecentThumbnails;
RecentDocsView* mpWriterRecentThumbnails; RecentDocsView* mpWriterRecentThumbnails;
RecentDocsView* mpCalcRecentThumbnails; RecentDocsView* mpCalcRecentThumbnails;
...@@ -78,6 +92,11 @@ class BackingWindow ...@@ -78,6 +92,11 @@ class BackingWindow
RecentDocsView* mpDatabaseRecentThumbnails; RecentDocsView* mpDatabaseRecentThumbnails;
RecentDocsView* mpMathRecentThumbnails; RecentDocsView* mpMathRecentThumbnails;
TemplateLocalView* mpWriterTemplateThumbnails;
TemplateLocalView* mpCalcTemplateThumbnails;
TemplateLocalView* mpImpressTemplateThumbnails;
TemplateLocalView* mpDrawTemplateThumbnails;
Rectangle maStartCentButtons; Rectangle maStartCentButtons;
bool mbInitControls; bool mbInitControls;
...@@ -88,6 +107,7 @@ class BackingWindow ...@@ -88,6 +107,7 @@ class BackingWindow
const OUString& rURL, const std::set<OUString>& rURLS, SvtModuleOptions& rOpt, const OUString& rURL, const std::set<OUString>& rURLS, SvtModuleOptions& rOpt,
SvtModuleOptions::EModule eMod ); SvtModuleOptions::EModule eMod );
void setupButton( PushButton* pButton ); void setupButton( PushButton* pButton );
void setupTemplateView( TemplateLocalView* pView, FILTER_APPLICATION eFilter );
void setupExternalLink( PushButton* pButton ); void setupExternalLink( PushButton* pButton );
void dispatchURL( const OUString& i_rURL, void dispatchURL( const OUString& i_rURL,
...@@ -97,6 +117,8 @@ class BackingWindow ...@@ -97,6 +117,8 @@ class BackingWindow
); );
DECL_LINK( ClickHdl, Button* ); DECL_LINK( ClickHdl, Button* );
DECL_LINK( RecentTemplateToggleHdl, Button* );
DECL_LINK( OpenTemplateHdl, ThumbnailViewItem* );
DECL_LINK( ExtLinkClickHdl, Button* ); DECL_LINK( ExtLinkClickHdl, Button* );
DECL_LINK( WindowEventListener, VclSimpleEvent* ); DECL_LINK( WindowEventListener, VclSimpleEvent* );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment