[Libreoffice-commits] core.git: Branch 'feature/template_manager_improvements' - sfx2/source

Efe Gürkan YALAMAN efeyalaman at gmail.com
Wed Jun 25 04:38:28 PDT 2014


 sfx2/source/dialog/backingwindow.cxx |  159 +++++++++++++++++++++++------------
 sfx2/source/dialog/backingwindow.hxx |   11 +-
 2 files changed, 113 insertions(+), 57 deletions(-)

New commits:
commit 661e12f5dae20db37fca3806cb9ef06b0d8b35ba
Author: Efe Gürkan YALAMAN <efeyalaman at gmail.com>
Date:   Wed Jun 25 14:36:34 2014 +0300

    Selecting and opening templates implemented.
    
    All editing related code commented out. Code needs to be cleaned up.
    
    Change-Id: Ibe901684d8747552b8ebeeea848c8f5e050ae726

diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index 3b0a342..8cc1f3a 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -281,18 +281,21 @@ void BackingWindow::initControls()
 
     mpViewBar->SetButtonType(BUTTON_SYMBOLTEXT);
     mpViewBar->SetItemBits(mpViewBar->GetItemId("repository"), TIB_DROPDOWNONLY);
-    mpViewBar->SetClickHdl(LINK(this,BackingWindow,TBXViewHdl));
+    //mpViewBar->SetClickHdl(LINK(this,BackingWindow,TBXViewHdl));
     //mpViewBar->SetDropdownClickHdl(LINK(this,BackingWindow,TBXDropdownHdl));
     mpViewBar->Hide();
+    mpViewBar->HideItem("import");
 
     mpTemplateBar->SetButtonType(BUTTON_SYMBOLTEXT);
     mpTemplateBar->SetItemBits(mpTemplateBar->GetItemId(TEMPLATEBAR_MOVE), TIB_DROPDOWNONLY);
-    mpTemplateBar->SetClickHdl( LINK( this, BackingWindow,TBXTemplateHdl ) );
+    //mpTemplateBar->SetClickHdl( LINK( this, BackingWindow,TBXTemplateHdl ) );
+    //mpTemplateBar->SetDoubleClickHdl( LINK(this, BackingWindow, OpenTemplateHdl) );
     //mpTemplateBar->SetDropdownClickHdl(LINK(this, BackingWindow,TBXDropdownHdl));
 
     //set handlers
     mpLocalView->setItemStateHdl(LINK(this, BackingWindow, TVItemStateHdl));
     mpLocalView->setOpenRegionHdl(LINK(this, BackingWindow, OpenRegionHdl));
+    mpLocalView->setOpenTemplateHdl(LINK(this,BackingWindow,OpenTemplateHdl));
 
     /*FIXME: Add other things for Local View
      *Filter and the bars*/
@@ -487,6 +490,8 @@ void BackingWindow::Resize()
         Invalidate();
 }
 
+//Editing related method
+/*
 void BackingWindow::OnTemplateImport ()
 {
     size_t nDialogType =
@@ -606,9 +611,10 @@ void BackingWindow::OnTemplateImport ()
             }
         }
     }
-}
+}*/
 
-void BackingWindow::OnFolderDelete()
+//Editing related method
+/*void BackingWindow::OnFolderDelete()
 {
     QueryBox aQueryDlg(this, WB_YES_NO | WB_DEF_YES, SfxResId(STR_QMSG_SEL_FOLDER_DELETE).toString());
 
@@ -640,10 +646,10 @@ void BackingWindow::OnFolderDelete()
         OUString aMsg( SfxResId(STR_MSG_ERROR_DELETE_FOLDER).toString() );
         ErrorBox(this, WB_OK,aMsg.replaceFirst("$1",aFolderList)).Execute();
     }
-}
+}*/
 
-
-void BackingWindow::OnFolderNew()
+//Editing related method
+/*void BackingWindow::OnFolderNew()
 {
     InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this);
 
@@ -655,34 +661,34 @@ void BackingWindow::OnFolderNew()
 
         mpCurrentView->createRegion(aName);
     }
-}
-
-
-void BackingWindow::OnRegionState (const ThumbnailViewItem *pItem)
-{
-    if (pItem->isSelected())
-    {
-        if (maSelFolders.empty() && !mbIsSaveMode)
-        {
-            mpViewBar->ShowItem("import");
-            mpViewBar->ShowItem("delete");
-            mpViewBar->HideItem("new_folder");
-        }
-
-        maSelFolders.insert(pItem);
-    }
-    else
-    {
-        maSelFolders.erase(pItem);
-
-        if (maSelFolders.empty() && !mbIsSaveMode)
-        {
-            mpViewBar->HideItem("import");
-            mpViewBar->HideItem("delete");
-            mpViewBar->ShowItem("new_folder");
-        }
-    }
-}
+}*/
+
+
+// void BackingWindow::OnRegionState (const ThumbnailViewItem *pItem)
+// {
+//     if (pItem->isSelected())
+//     {
+//         if (maSelFolders.empty() && !mbIsSaveMode)
+//         {
+//             mpViewBar->ShowItem("import");
+//             mpViewBar->ShowItem("delete");
+//             mpViewBar->HideItem("new_folder");
+//         }
+
+//         maSelFolders.insert(pItem);
+//     }
+//     else
+//     {
+//         maSelFolders.erase(pItem);
+
+//         if (maSelFolders.empty() && !mbIsSaveMode)
+//         {
+//             mpViewBar->HideItem("import");
+//             mpViewBar->HideItem("delete");
+//             mpViewBar->ShowItem("new_folder");
+//         }
+//     }
+// }
 
 
 IMPL_LINK(BackingWindow, ExtLinkClickHdl, Button*, pButton)
@@ -764,36 +770,83 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton )
 */
         mpAllRecentThumbnails->Hide();
         mpLocalView->Show();
-        mpViewBar->Show();
+        mpViewBar->Hide();
+        mpViewBar->HideItem("import");
+        mpViewBar->HideItem("delete");
+        mpViewBar->HideItem("new_folder");
     }
     return 0;
 }
 
+IMPL_LINK_NOARG(BackingWindow, DoubleClickHdl)
+{
+    ThumbnailViewItem *pItem = const_cast<ThumbnailViewItem*>(*maSelTemplates.begin());
+
+    OpenTemplateHdl(pItem);
+    return 0;
+}
+
+
 //FIXME: Obvious enough
 IMPL_LINK_NOARG( BackingWindow, OpenRegionHdl)
 {
     maSelFolders.clear();
     maSelTemplates.clear();
 
-    mpViewBar->ShowItem("new_folder", mpCurrentView->isNestedRegionAllowed());
+    //mpViewBar->ShowItem("new_folder", mpCurrentView->isNestedRegionAllowed());
 
-    if (!mbIsSaveMode)
-        mpViewBar->ShowItem("import", mpCurrentView->isImportAllowed());
+    //if (!mbIsSaveMode)
+      //  mpViewBar->ShowItem("import", mpCurrentView->isImportAllowed());
 
-    //mpTemplateBar->Hide();
-    mpViewBar->Show();
+    mpTemplateBar->Hide();
+    mpViewBar->Hide();
+    mpViewBar->HideItem("import");
+    mpViewBar->HideItem("delete");
+    mpViewBar->HideItem("new_folder");
     //mpActionBar->Show();
 
     return 0;
 }
 
-//FIXME: Implement OnSomething() methods
-IMPL_LINK_NOARG(BackingWindow,TBXViewHdl)
+//FIXME: Cleanup the code
+IMPL_LINK(BackingWindow, OpenTemplateHdl, ThumbnailViewItem*, pItem)
 {
-    const size_t nCurItemId = mpViewBar->GetCurItemId();
+    if (!mbIsSaveMode)
+    {
+        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);
+
+        Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY );
+
+        try
+        {
+            dispatchURL( pTemplateItem->getPath(), "_default", xFrame, aArgs );
+            //mxDesktop->loadComponentFromURL(pTemplateItem->getPath(),"_default", 0, aArgs );
+        }
+        catch( const uno::Exception& )
+        {
+        }
+    }
+
+    return 0;
+}
 
-    if (nCurItemId == mpViewBar->GetItemId("import"))
-        OnTemplateImport();
+//FIXME: Implement OnSomething() methods
+//IMPL_LINK_NOARG(BackingWindow,TBXViewHdl)
+//{
+  //  const size_t nCurItemId = mpViewBar->GetCurItemId();
+
+    /*//if (nCurItemId == mpViewBar->GetItemId("import"))
+      //  OnTemplateImport();
     else if (nCurItemId == mpViewBar->GetItemId("delete"))
     {
         if (mpCurrentView == mpLocalView)
@@ -805,11 +858,11 @@ IMPL_LINK_NOARG(BackingWindow,TBXViewHdl)
         OnFolderNew();
     //else if (nCurItemId == mpViewBar->GetItemId("save"))
         ////OnTemplateSaveAs();
+    */
+    //return 0;
+//}
 
-    return 0;
-}
-
-//FIXME: Implement OnSomething() methods
+//FIXME: Implement OnSomething() methods // might be deleted
 IMPL_LINK_NOARG(BackingWindow,TBXTemplateHdl)
 {
     //const size_t nCurItemId = mpTemplateBar->GetCurItemId();
@@ -833,10 +886,10 @@ IMPL_LINK_NOARG(BackingWindow,TBXTemplateHdl)
 
 IMPL_LINK(BackingWindow, TVItemStateHdl, const ThumbnailViewItem*, pItem)
 {
-    const TemplateContainerItem *pCntItem = dynamic_cast<const TemplateContainerItem*>(pItem);
+    //const TemplateContainerItem *pCntItem = dynamic_cast<const TemplateContainerItem*>(pItem);
 
-    if (pCntItem)
-        OnRegionState(pItem);
+    //if (pCntItem)
+        //OnRegionState(pItem);
     //else
         //FIXME:Move this to here
         //OnTemplateState(pItem);
diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx
index f46596f..452ada2 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -99,10 +99,11 @@ class BackingWindow
 
     void setupButton( PushButton* pButton );
     //Template Manager
-    void OnTemplateImport ();
-    void OnFolderNew ();
-    void OnFolderDelete ();
-    void OnRegionState (const ThumbnailViewItem *pItem);
+    void OnTemplateOpen ();
+    //void OnTemplateImport ();
+    //void OnFolderNew ();
+    //void OnFolderDelete ();
+    //void OnRegionState (const ThumbnailViewItem *pItem);
 
     void dispatchURL( const OUString& i_rURL,
                       const OUString& i_rTarget = OUString( "_default" ),
@@ -119,6 +120,8 @@ class BackingWindow
     DECL_LINK(TBXViewHdl, void*);
     DECL_LINK(TBXTemplateHdl, void*);
     DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*);
+    DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*);
+    DECL_LINK(DoubleClickHdl, void*);
 
     void initControls();
 


More information about the Libreoffice-commits mailing list