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 @@
<glade-widget-class title="Recent Documents View" name="sfxlo-RecentDocsView"
generic-name="Icon View" parent="GtkIconView"
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-catalog>
......@@ -81,8 +81,8 @@ class SFX2_DLLPUBLIC TemplateAbstractView : public ThumbnailView
public:
TemplateAbstractView (Window *pParent, WinBits nWinStyle, bool bDisableTransientChildren);
TemplateAbstractView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
TemplateAbstractView ( Window* pParent );
virtual ~TemplateAbstractView ();
......
......@@ -30,6 +30,7 @@ class SFX2_DLLPUBLIC TemplateLocalView : public TemplateAbstractView
public:
TemplateLocalView ( Window* pParent, const ResId& rResId, bool bDisableTransientChildren = false );
TemplateLocalView ( Window* pParent );
virtual ~TemplateLocalView ();
......
......@@ -142,6 +142,18 @@ TemplateAbstractView::TemplateAbstractView(Window *pParent, const ResId &rResId,
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 ()
{
}
......
......@@ -16,6 +16,7 @@
#include <svl/inettype.hxx>
#include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <vcl/builder.hxx>
#include <vcl/pngread.hxx>
#include <com/sun/star/embed/ElementModes.hpp>
......@@ -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()
{
for (size_t i = 0; i < maRegions.size(); ++i)
......
......@@ -31,6 +31,8 @@
#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/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
......@@ -38,11 +40,13 @@
#include <com/sun/star/system/SystemShellExecute.hpp>
#include <com/sun/star/system/SystemShellExecuteFlags.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::frame;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
using namespace ::com::sun::star::document;
const char RECENT_FILE_LIST[] = ".uno:RecentFileList";
......@@ -60,8 +64,15 @@ const int nItemId_Extensions = 1;
const int nItemId_Info = 3;
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 ) :
Window( i_pParent ),
mxDesktop( Desktop::create(comphelper::getProcessComponentContext()) ),
mbInitControls( false ),
mnHideExternalLinks( 0 ),
mpAccExec( NULL )
......@@ -93,6 +104,16 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get(mpInfoButton, "info");
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( mpWriterRecentThumbnails, "writer_recent");
get( mpCalcRecentThumbnails, "calc_recent");
......@@ -101,6 +122,11 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
get( mpDatabaseRecentThumbnails, "database_recent");
get( mpMathRecentThumbnails, "math_recent");
get( mpWriterTemplateThumbnails, "writer_templates");
get( mpCalcTemplateThumbnails, "calc_templates");
get( mpImpressTemplateThumbnails, "impress_templates");
get( mpDrawTemplateThumbnails, "draw_templates");
try
{
mxContext.set( ::comphelper::getProcessComponentContext(), uno::UNO_SET_THROW );
......@@ -158,6 +184,10 @@ BackingWindow::BackingWindow( Window* i_pParent ) :
BackingWindow::~BackingWindow()
{
mpWriterTemplateThumbnails ->setOpenTemplateHdl(Link());
mpCalcTemplateThumbnails ->setOpenTemplateHdl(Link());
mpImpressTemplateThumbnails ->setOpenTemplateHdl(Link());
mpDrawTemplateThumbnails ->setOpenTemplateHdl(Link());
}
IMPL_LINK( BackingWindow, WindowEventListener, VclSimpleEvent*, pEvent )
......@@ -247,6 +277,26 @@ void BackingWindow::initControls()
setupExternalLink( mpInfoButton );
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();
}
......@@ -281,6 +331,20 @@ void BackingWindow::setupButton( PushButton* pButton )
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 )
{
if( mnHideExternalLinks == 0 )
......@@ -441,6 +505,96 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
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
{
Reference< XDispatch > xDispatch;
......
......@@ -28,6 +28,8 @@
#include <vcl/layout.hxx>
#include <sfx2/recentdocsview.hxx>
#include <sfx2/templatelocalview.hxx>
#include <sfx2/templateviewitem.hxx>
#include <svtools/acceleratorexecute.hxx>
#include <unotools/moduleoptions.hxx>
......@@ -36,6 +38,7 @@
#include <com/sun/star/frame/XDispatchProvider.hpp>
#include <com/sun/star/frame/XDesktop.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XDesktop2.hpp>
#include <set>
......@@ -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::frame::XDispatchProvider > mxDesktopDispatchProvider;
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* mpTemplateButton;
......@@ -70,6 +74,16 @@ class BackingWindow
PushButton* mpInfoButton;
PushButton* mpTplRepButton;
PushButton* mpShowWriterTemplateButton;
PushButton* mpShowCalcTemplateButton;
PushButton* mpShowImpressTemplateButton;
PushButton* mpShowDrawTemplateButton;
PushButton* mpShowWriterRecentButton;
PushButton* mpShowCalcRecentButton;
PushButton* mpShowImpressRecentButton;
PushButton* mpShowDrawRecentButton;
RecentDocsView* mpAllRecentThumbnails;
RecentDocsView* mpWriterRecentThumbnails;
RecentDocsView* mpCalcRecentThumbnails;
......@@ -78,6 +92,11 @@ class BackingWindow
RecentDocsView* mpDatabaseRecentThumbnails;
RecentDocsView* mpMathRecentThumbnails;
TemplateLocalView* mpWriterTemplateThumbnails;
TemplateLocalView* mpCalcTemplateThumbnails;
TemplateLocalView* mpImpressTemplateThumbnails;
TemplateLocalView* mpDrawTemplateThumbnails;
Rectangle maStartCentButtons;
bool mbInitControls;
......@@ -88,6 +107,7 @@ class BackingWindow
const OUString& rURL, const std::set<OUString>& rURLS, SvtModuleOptions& rOpt,
SvtModuleOptions::EModule eMod );
void setupButton( PushButton* pButton );
void setupTemplateView( TemplateLocalView* pView, FILTER_APPLICATION eFilter );
void setupExternalLink( PushButton* pButton );
void dispatchURL( const OUString& i_rURL,
......@@ -97,6 +117,8 @@ class BackingWindow
);
DECL_LINK( ClickHdl, Button* );
DECL_LINK( RecentTemplateToggleHdl, Button* );
DECL_LINK( OpenTemplateHdl, ThumbnailViewItem* );
DECL_LINK( ExtLinkClickHdl, Button* );
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