[Libreoffice-commits] .: 16 commits - framework/uiconfig sfx2/inc sfx2/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Sat Aug 11 17:28:41 PDT 2012


 framework/uiconfig/startmodule/menubar/menubar.xml |    1 
 sfx2/inc/sfx2/templateabstractview.hxx             |    2 
 sfx2/inc/sfx2/templatelocalview.hxx                |    2 
 sfx2/inc/sfx2/templateonlineview.hxx               |    3 
 sfx2/inc/sfx2/templateproperties.hxx               |    3 
 sfx2/inc/templatedlg.hxx                           |    6 
 sfx2/source/control/templateabstractview.cxx       |    5 
 sfx2/source/control/templatelocalview.cxx          |  110 +++++++++++++-----
 sfx2/source/control/templateonlineview.cxx         |   17 +-
 sfx2/source/doc/templatedlg.cxx                    |  127 ++++++++++++++++-----
 sfx2/source/doc/templatedlg.hrc                    |    3 
 sfx2/source/doc/templatedlg.src                    |   13 --
 12 files changed, 215 insertions(+), 77 deletions(-)

New commits:
commit a910970f4914eb96cdd9f331033b8a2f84315007
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 19:56:45 2012 -0430

    Remove Template Manager menu entry from start center.
    
    Change-Id: Id5b24883c5a03abbc18c88cec910b00a5d0e3dfe

diff --git a/framework/uiconfig/startmodule/menubar/menubar.xml b/framework/uiconfig/startmodule/menubar/menubar.xml
index cba848f..20619c4 100644
--- a/framework/uiconfig/startmodule/menubar/menubar.xml
+++ b/framework/uiconfig/startmodule/menubar/menubar.xml
@@ -14,7 +14,6 @@
             <menu:menuitem menu:id=".uno:SaveAll"/>
             <menu:menuseparator/>
             <menu:menuitem menu:id=".uno:SendMail"/>
-            <menu:menuitem menu:id=".uno:TemplateManager"/>
             <menu:menu menu:id=".uno:TemplateMenu">
                 <menu:menupopup>
                     <menu:menuitem menu:id=".uno:Organizer"/>
commit a7b9e624ac24f2af02f53930f75ebf36f1cdfa0d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 19:45:16 2012 -0430

    Change repository name and update repository menu list.
    
    Change-Id: I9e29795d93481bb0789e4f05fa2605b6407efc8c

diff --git a/sfx2/inc/sfx2/templateonlineview.hxx b/sfx2/inc/sfx2/templateonlineview.hxx
index aed70d2..0d88d0b 100644
--- a/sfx2/inc/sfx2/templateonlineview.hxx
+++ b/sfx2/inc/sfx2/templateonlineview.hxx
@@ -34,6 +34,8 @@ public:
 
     virtual void showOverlay (bool bVisible);
 
+    void setOverlayChangeNameHdl (const Link &rLink);
+
     bool loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh);
 
     const std::vector<TemplateOnlineViewItem*>& getRepositories () const { return maRepositories; }
@@ -53,6 +55,7 @@ private:
 private:
 
     bool mbIsSynced;
+    Link maChangeNameHdl;
     std::vector<TemplateOnlineViewItem*> maRepositories;
     com::sun::star::uno::Reference< com::sun::star::ucb::XCommandEnvironment > m_xCmdEnv;
 };
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index c50eec2..bed10a6 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -70,6 +70,8 @@ private:
 
     DECL_LINK(SearchUpdateHdl, void*);
 
+    DECL_LINK(RepositoryChangeNameHdl, void*);
+
     void OnTemplateImport ();
     void OnTemplateSearch ();
     void OnTemplateEdit ();
diff --git a/sfx2/source/control/templateonlineview.cxx b/sfx2/source/control/templateonlineview.cxx
index 9828489..2133752 100644
--- a/sfx2/source/control/templateonlineview.cxx
+++ b/sfx2/source/control/templateonlineview.cxx
@@ -118,6 +118,11 @@ void TemplateOnlineView::showOverlay (bool bVisible)
     }
 }
 
+void TemplateOnlineView::setOverlayChangeNameHdl(const Link &rLink)
+{
+    maChangeNameHdl = rLink;
+}
+
 bool TemplateOnlineView::loadRepository (const sal_uInt16 nRepositoryId, bool bRefresh)
 {
     TemplateOnlineViewItem *pItem = NULL;
@@ -319,16 +324,18 @@ void TemplateOnlineView::setItemDimensions(long ItemWidth, long ThumbnailHeight,
 
 IMPL_LINK (TemplateOnlineView, ChangeNameHdl, TemplateView*, pView)
 {
-    bool bRet = true;
-    mbIsSynced = false;
+    bool bRet = false;
 
     // check if there isnt another repository with the same name.
     for (size_t i = 0, n = maRepositories.size(); i < n; ++i)
     {
-        if (maRepositories[i]->maTitle == pView->getName())
+        if (maRepositories[i]->mnId == pView->getId())
         {
-            bRet = false;
-            mbIsSynced = true;
+            maRepositories[i]->maTitle = pView->getName();
+
+            bRet = true;
+            mbIsSynced = false;
+            maChangeNameHdl.Call(this);
             break;
         }
     }
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 630353d..bc83ecf 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -222,6 +222,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     mpOnlineView->setOverlayItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
     mpOnlineView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
     mpOnlineView->setOverlayCloseHdl(LINK(this,SfxTemplateManagerDlg,CloseOverlayHdl));
+    mpOnlineView->setOverlayChangeNameHdl(LINK(this,SfxTemplateManagerDlg,RepositoryChangeNameHdl));
 
     mpSearchView->SetSizePixel(aThumbSize);
     mpSearchView->setItemMaxTextLength(ITEM_MAX_TEXT_LENGTH);
@@ -692,6 +693,12 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, SearchUpdateHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG (SfxTemplateManagerDlg, RepositoryChangeNameHdl)
+{
+    createRepositoryMenu();
+    return 0;
+}
+
 void SfxTemplateManagerDlg::OnTemplateImport ()
 {
     sal_Int16 nDialogType =
commit 53c0b9533fb2225da0bed755eca9fe696f191096
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 18:09:22 2012 -0430

    Remove unused attribute.
    
    Change-Id: Ie0a5198a4acdb7e0509eb1d867f722a5270823e7

diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index f3012b0..c50eec2 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -128,7 +128,6 @@ private:
     PopupMenu *mpRepositoryMenu;
     PopupMenu *mpTemplateDefaultMenu;
 
-    int mnSelectionCount;
     std::set<const ThumbnailViewItem*> maSelTemplates;
     std::set<const ThumbnailViewItem*> maSelFolders;
 
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 20d4654..630353d 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -120,7 +120,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
       mpSearchView(new TemplateSearchView(this)),
       maView(new TemplateLocalView(this,SfxResId(TEMPLATE_VIEW))),
       mpOnlineView(new TemplateOnlineView(this, WB_VSCROLL,false)),
-      mnSelectionCount(0),
       mxDesktop(comphelper::getProcessServiceFactory()->createInstance( "com.sun.star.frame.Desktop" ),uno::UNO_QUERY )
 {
     maButtonSelMode.SetStyle(maButtonSelMode.GetStyle() | WB_TOGGLE);
commit e0103e5b418ef162b91860586bfc630423afc1b3
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 18:04:00 2012 -0430

    Show action bar after closing overlay.
    
    Change-Id: I5c9f4b48a5999974d8605d0fd18215bc5421f22c

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index b1625b2..20d4654 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -324,6 +324,7 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg, CloseOverlayHdl)
     maSelTemplates.clear();
     mpTemplateBar->Hide();
     mpViewBar->Show();
+    mpActionBar->Show();
 
     if (mpCurView == maView)
         mpCurView->showOverlay(false);
commit d2597d874fcbf43364ecf79e6ad88fe4d838f781
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 18:00:35 2012 -0430

    Hide template bar after deleting selected templates.
    
    Change-Id: Ia6f874bcced622ab564ffc5b065d4a2c4ed246c0

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index d4d366d..b1625b2 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -949,6 +949,14 @@ void SfxTemplateManagerDlg::OnTemplateDelete ()
             else
                 ++pIter;
         }
+
+        if (maSelTemplates.empty())
+        {
+            mpTemplateBar->SetItemDown(TBI_TEMPLATE_DELETE,false);
+            mpTemplateBar->Show(false);
+            mpViewBar->Show();
+            mpActionBar->Show();
+        }
     }
 }
 
commit 4f6cf1f989de6e7d2ea63bcb84957ed2fbd039a2
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 17:39:51 2012 -0430

    Remove unneeded calls.
    
    Change-Id: I9a461ab81e3cf5f8e8c3a9add2084c082bc4797f

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 88de99b..d4d366d 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -967,12 +967,6 @@ void SfxTemplateManagerDlg::OnTemplateAsDefault ()
 
         // clear selection and display view/action toolbars
         maView->deselectOverlayItem(pItem->mnId);
-        maSelTemplates.clear();
-
-        mpTemplateBar->SetItemDown(TBI_TEMPLATE_DEFAULT,false);
-        mpTemplateBar->Show(false);
-        mpViewBar->Show();
-        mpActionBar->Show();
     }
 }
 
commit 999f1ec455de32a8e4039cdc1c4d992902fe88e1
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 16:10:01 2012 -0430

    Deselect overlay items after exporting them.
    
    Change-Id: Ie291951c421c330f6b0da9fc9d385d222e698ef1

diff --git a/sfx2/inc/sfx2/templateabstractview.hxx b/sfx2/inc/sfx2/templateabstractview.hxx
index 58fec13..9bd7594 100644
--- a/sfx2/inc/sfx2/templateabstractview.hxx
+++ b/sfx2/inc/sfx2/templateabstractview.hxx
@@ -79,6 +79,8 @@ public:
     // Check if the overlay is visible or not.
     bool isOverlayVisible () const;
 
+    void deselectOverlayItems ();
+
     void deselectOverlayItem (const sal_uInt16 nItemId);
 
     void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*,
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index d4c92f7..375012a 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -85,6 +85,11 @@ bool TemplateAbstractView::isOverlayVisible () const
     return mpItemView->IsVisible();
 }
 
+void TemplateAbstractView::deselectOverlayItems()
+{
+    mpItemView->deselectItems();
+}
+
 void TemplateAbstractView::deselectOverlayItem(const sal_uInt16 nItemId)
 {
     mpItemView->deselectItem(nItemId);
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 256c0d1..88de99b 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -834,6 +834,8 @@ void SfxTemplateManagerDlg::OnTemplateExport()
                 {
                 }
             }
+
+            maView->deselectOverlayItems();
         }
     }
 }
commit f8ae1423a45f600edc49388565faf90b49833682
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 13:56:35 2012 -0430

    Export templates displayed in the search view.
    
    Change-Id: Ic970ba4c3372756193834a5adf41dfe72c3ab5f0

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 5b3d843..256c0d1 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -786,6 +786,28 @@ void SfxTemplateManagerDlg::OnTemplateExport()
 
         if (mpSearchView->IsVisible())
         {
+            sal_uInt16 i = 1;
+
+            std::set<const ThumbnailViewItem*>::const_iterator pIter = maSelTemplates.begin();
+            for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter, ++i)
+            {
+                const TemplateSearchViewItem *pItem = static_cast<const TemplateSearchViewItem*>(*pIter);
+
+                INetURLObject aItemPath(pItem->getPath());
+
+                if ( 1 == i )
+                    aPathObj.Append(aItemPath.getName());
+                else
+                    aPathObj.setName(aItemPath.getName());
+
+                OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
+
+                if (!maView->exportTo(pItem->mnIdx+1,pItem->mnRegionId+1,aPath))
+                {
+                }
+            }
+
+            mpSearchView->deselectItems();
         }
         else
         {
commit 4661cfee1c7ad51ce623ecdded0a42805fbdce53
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 13:13:01 2012 -0430

    Export selected overlay templates.
    
    Change-Id: Id22c8a621987875def8416e50e03a04b89909f70

diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx
index 7b5984b..f3d4ec6 100644
--- a/sfx2/inc/sfx2/templatelocalview.hxx
+++ b/sfx2/inc/sfx2/templatelocalview.hxx
@@ -55,6 +55,8 @@ public:
 
     void copyFrom (TemplateLocalViewItem *pItem, const rtl::OUString &rPath);
 
+    bool exportTo (const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName);
+
 private:
 
     virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem);
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 399d22a..f3012b0 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -76,6 +76,7 @@ private:
     void OnTemplateProperties ();
     void OnTemplateDelete ();
     void OnTemplateAsDefault ();
+    void OnTemplateExport ();
     void OnFolderDelete ();
     void OnRepositoryDelete ();
 
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 3679cf8..e4c07c7 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -609,6 +609,36 @@ void TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const rtl::OUStr
     }
 }
 
+bool TemplateLocalView::exportTo(const sal_uInt16 nItemId, const sal_uInt16 nRegionItemId, const OUString &rName)
+{
+    sal_uInt16 nRegionId = nRegionItemId - 1;
+
+    for (size_t i = 0, n = mItemList.size(); i < n; ++i)
+    {
+        if (mItemList[i]->mnId == nRegionItemId)
+        {
+            TemplateLocalViewItem *pRegItem =
+                    static_cast<TemplateLocalViewItem*>(mItemList[i]);
+
+            std::vector<TemplateItemProperties>::iterator aIter;
+            for (aIter = pRegItem->maTemplates.begin(); aIter != pRegItem->maTemplates.end(); ++aIter)
+            {
+                if (aIter->nId == nItemId)
+                {
+                    if (!mpDocTemplates->CopyTo(nRegionId,aIter->nDocId,rName))
+                        return false;
+
+                    return true;
+                }
+            }
+
+            break;
+        }
+    }
+
+    return false;
+}
+
 void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
 {
     // Fill templates
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index b1e1b83..5b3d843 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -31,6 +31,7 @@
 #include <svtools/PlaceEditDialog.hxx>
 #include <tools/urlobj.hxx>
 #include <unotools/moduleoptions.hxx>
+#include <unotools/pathoptions.hxx>
 #include <vcl/edit.hxx>
 #include <vcl/msgbox.hxx>
 #include <vcl/toolbox.hxx>
@@ -42,7 +43,9 @@
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
 
 #include "doc.hrc"
 #include "templatedlg.hrc"
@@ -64,6 +67,8 @@ using namespace ::com::sun::star;
 using namespace ::com::sun::star::beans;
 using namespace ::com::sun::star::embed;
 using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ui::dialogs;
 
 void lcl_createTemplate(uno::Reference<XComponentLoader> xDesktop, const FILTER_APPLICATION eApp);
 
@@ -384,6 +389,9 @@ IMPL_LINK_NOARG(SfxTemplateManagerDlg,TBXTemplateHdl)
     case TBI_TEMPLATE_DEFAULT:
         OnTemplateAsDefault();
         break;
+    case TBI_TEMPLATE_EXPORT:
+        OnTemplateExport();
+        break;
     default:
         break;
     }
@@ -762,6 +770,52 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
     }
 }
 
+void SfxTemplateManagerDlg::OnTemplateExport()
+{
+    uno::Reference<XMultiServiceFactory> xFactory(comphelper::getProcessServiceFactory());
+    uno::Reference<XFolderPicker> xFolderPicker(xFactory->createInstance(FOLDER_PICKER_SERVICE_NAME),uno::UNO_QUERY);
+
+    xFolderPicker->setDisplayDirectory(SvtPathOptions().GetWorkPath());
+
+    sal_Int16 nResult = xFolderPicker->execute();
+
+    if( nResult == ExecutableDialogResults::OK )
+    {
+        INetURLObject aPathObj(xFolderPicker->getDirectory());
+        aPathObj.setFinalSlash();
+
+        if (mpSearchView->IsVisible())
+        {
+        }
+        else
+        {
+            // export templates from the current open overlay
+
+            sal_uInt16 i = 1;
+            sal_uInt16 nRegionItemId = maView->getOverlayRegionId() + 1;
+
+            std::set<const ThumbnailViewItem*>::const_iterator pIter = maSelTemplates.begin();
+            for (pIter = maSelTemplates.begin(); pIter != maSelTemplates.end(); ++pIter, ++i)
+            {
+                const TemplateViewItem *pItem = static_cast<const TemplateViewItem*>(*pIter);
+
+                INetURLObject aItemPath(pItem->getPath());
+
+                if ( 1 == i )
+                    aPathObj.Append(aItemPath.getName());
+                else
+                    aPathObj.setName(aItemPath.getName());
+
+                OUString aPath = aPathObj.GetMainURL( INetURLObject::NO_DECODE );
+
+                if (!maView->exportTo(pItem->mnId,nRegionItemId,aPath))
+                {
+                }
+            }
+        }
+    }
+}
+
 void SfxTemplateManagerDlg::OnTemplateSearch ()
 {
     Point aPos = maView->GetPosPixel();
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index 8d1c96a..9bdedae 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -28,6 +28,7 @@
 #define TBI_TEMPLATE_MOVE           17
 #define TBI_TEMPLATE_DELETE         18
 #define TBI_TEMPLATE_DEFAULT        19
+#define TBI_TEMPLATE_EXPORT         20
 
 #define MNI_ACTION_REFRESH          22
 #define MNI_ACTION_SORT_NAME        23
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index 5d17738..900b481 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -236,6 +236,12 @@ ModelessDialog DLG_TEMPLATE_MANAGER
 
             ToolBoxItem
             {
+                Identifier = TBI_TEMPLATE_EXPORT;
+                Text [ en-US ] = "Export";
+            };
+
+            ToolBoxItem
+            {
                 Identifier = TBI_TEMPLATE_DELETE;
                 Text [ en-US ] = "Delete";
             };
commit 9d88c7a34f148925a95d14f03e105f9c62f293a3
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 09:49:57 2012 -0430

    Remove close button in template dialog.
    
    Change-Id: I7a8cac7b8dfa73eabea9113d4b9921a2d48b0324

diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index 91bc0be..399d22a 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -49,7 +49,6 @@ private:
 
     virtual void MouseButtonDown( const MouseEvent& rMEvt );
 
-    DECL_LINK(CloseHdl, void*);
     DECL_LINK(CloseOverlayHdl, void*);
 
     DECL_LINK(OnClickSelectionMode, ImageButton*);
@@ -114,7 +113,6 @@ private:
     PushButton aButtonPresents;
     PushButton aButtonSheets;
     PushButton aButtonDraws;
-    PushButton maButtonClose;
     ImageButton maButtonSelMode;
 
     Edit *mpSearchEdit;
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 8352234..b1e1b83 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -107,7 +107,6 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
       aButtonPresents(this,SfxResId(BTN_SELECT_PRESENTATIONS)),
       aButtonSheets(this,SfxResId(BTN_SELECT_SHEETS)),
       aButtonDraws(this,SfxResId(BTN_SELECT_DRAWS)),
-      maButtonClose(this,SfxResId(BTN_TEMPLATE_CLOSE)),
       maButtonSelMode(this,SfxResId(BTN_SELECTION_MODE)),
       mpSearchEdit(new Edit(this,WB_HIDE | WB_BORDER)),
       mpViewBar( new ToolBox(this, SfxResId(TBX_ACTION_VIEW))),
@@ -229,22 +228,11 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
 
     mpSearchView->setItemStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
 
-    // Set OK button position
-    Point aBtnPos;
-    Size aBtnSize = maButtonClose.GetSizePixel();
-    aBtnPos.setX(aWinSize.getWidth() - PADDING_DLG_BORDER - aBtnSize.getWidth());
-    aBtnPos.setY(aViewPos.getY()+aThumbSize.getHeight() + PADDING_TOOLBAR_VIEW);
-    maButtonClose.SetPosPixel(aBtnPos);
-
-    if (aWinSize.getHeight() != aBtnPos.getY() + aBtnSize.getHeight() + PADDING_DLG_BORDER )
-        aWinSize.setHeight(aBtnPos.getY() + aBtnSize.getHeight() + PADDING_DLG_BORDER);
-
     aButtonAll.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewAllHdl));
     aButtonDocs.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDocsHdl));
     aButtonPresents.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewPresentsHdl));
     aButtonSheets.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewSheetsHdl));
     aButtonDraws.SetClickHdl(LINK(this,SfxTemplateManagerDlg,ViewDrawsHdl));
-    maButtonClose.SetClickHdl(LINK(this,SfxTemplateManagerDlg,CloseHdl));
     maButtonSelMode.SetClickHdl(LINK(this,SfxTemplateManagerDlg,OnClickSelectionMode));
 
     // Set dialog to correct dimensions
@@ -326,12 +314,6 @@ void SfxTemplateManagerDlg::MouseButtonDown( const MouseEvent& rMEvt )
     }
 }
 
-IMPL_LINK_NOARG (SfxTemplateManagerDlg, CloseHdl)
-{
-    Close();
-    return 0;
-}
-
 IMPL_LINK_NOARG(SfxTemplateManagerDlg, CloseOverlayHdl)
 {
     maSelTemplates.clear();
@@ -783,7 +765,6 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
 void SfxTemplateManagerDlg::OnTemplateSearch ()
 {
     Point aPos = maView->GetPosPixel();
-    Point aClosePos = maButtonClose.GetPosPixel();
     bool bVisible = mpSearchEdit->IsVisible();
     Size aWinSize = GetSizePixel();
     long nEditHeight = mpSearchEdit->GetSizePixel().getHeight();
@@ -792,14 +773,12 @@ void SfxTemplateManagerDlg::OnTemplateSearch ()
     {
         aWinSize.setHeight(aWinSize.getHeight() - nEditHeight );
         aPos.setY(aPos.getY() - nEditHeight );
-        aClosePos.setY(aClosePos.getY() - nEditHeight );
         mpActionBar->SetItemState(TBI_TEMPLATE_SEARCH,STATE_NOCHECK);
     }
     else
     {
         aWinSize.setHeight(aWinSize.getHeight() + nEditHeight );
         aPos.setY(aPos.getY() + nEditHeight );
-        aClosePos.setY(aClosePos.getY() + nEditHeight );
         mpActionBar->SetItemState(TBI_TEMPLATE_SEARCH,STATE_CHECK);
     }
 
@@ -807,7 +786,6 @@ void SfxTemplateManagerDlg::OnTemplateSearch ()
     maView->SetPosPixel(aPos);
     mpOnlineView->SetPosPixel(aPos);
     mpSearchView->SetPosPixel(aPos);
-    maButtonClose.SetPosPixel(aClosePos);
 
     // Hide search view
     if (bVisible)
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index af9b137..8d1c96a 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -32,8 +32,6 @@
 #define MNI_ACTION_REFRESH          22
 #define MNI_ACTION_SORT_NAME        23
 
-#define BTN_TEMPLATE_CLOSE          24
-
 #define TBI_TEMPLATE_FOLDER_DEL     25
 #define TBI_TEMPLATE_REPOSITORY     26
 
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index e9e072d..5d17738 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -110,13 +110,6 @@ ModelessDialog DLG_TEMPLATE_MANAGER
         QuickHelpText [en-US] = "Enables selecting items by just clicking in the thumbnail or title.";
     };
 
-    PushButton BTN_TEMPLATE_CLOSE
-    {
-        Size = MAP_APPFONT(50,14);
-        TabStop = TRUE;
-        Text [en-US] = "Close";
-    };
-
     Control TEMPLATE_VIEW
     {
         Pos = MAP_APPFONT(5,30);
commit 3f660094c871a9fb06c6767fcc766c10989caa27
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 09:38:34 2012 -0430

    Update thumbnails after importing templates to a folder.
    
    Change-Id: I44afb92c27b58de3206a90b7aad4125d6860d6ba

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index d2d263a..8352234 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -774,6 +774,8 @@ void SfxTemplateManagerDlg::OnTemplateImport ()
                 for (size_t i = 0, n = aFiles.getLength(); i < n; ++i)
                     maView->copyFrom(pFolder,aFiles[i]);
             }
+
+            maView->Invalidate(INVALIDATE_NOERASE);
         }
     }
 }
@@ -1110,6 +1112,8 @@ void SfxTemplateManagerDlg::remoteMoveTo(const sal_uInt16 nMenuId)
 
             maView->copyFrom(nItemId,pItem->maPreview1,pItem->getPath());
         }
+
+        maView->Invalidate(INVALIDATE_NOERASE);
     }
 }
 
commit b6e7dabce95e165073ecc0c7b614b795768c4c88
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 09:31:04 2012 -0430

    Reset thumbnails before updating them.
    
    Change-Id: I24db95d8875a7a002de0492b4ac62093ddf7f874

diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 303e4d1..3679cf8 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -651,6 +651,9 @@ IMPL_LINK(TemplateLocalView, ChangeNameHdl, TemplateView*, pView)
 
 void lcl_updateThumbnails (TemplateLocalViewItem *pItem)
 {
+    pItem->maPreview1.Clear();
+    pItem->maPreview2.Clear();
+
     // Update folder thumbnails
     for (size_t i = 0, n = pItem->maTemplates.size(); i < 2 && i < n; ++i)
     {
commit c1149bb21895d313e57e28237e9dee7800e186e3
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 11 08:48:50 2012 -0430

    Fix importing from filesystem and from a remote repository.
    
    Change-Id: Ibf1845b87b2b34b1933e56a61036dbffc69daead

diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 78484ba..303e4d1 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -531,29 +531,37 @@ bool TemplateLocalView::moveTemplates(std::set<const ThumbnailViewItem *> &rItem
 void TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx &rThumbnail,
                                   const OUString &rPath)
 {
-    sal_uInt16 nId = 0;
     sal_uInt16 nRegionId = nRegionItemId - 1;
 
-    if (!mItemList.empty())
-        nId = (mItemList.back())->mnId;
+    for (size_t i = 0, n = mItemList.size(); i < n; ++i)
+    {
+        if (mItemList[i]->mnId == nRegionItemId)
+        {
+            sal_uInt16 nId = 0;
+            sal_uInt16 nDocId = 0;
 
-    String aPath(rPath);
+            TemplateLocalViewItem *pRegionItem =
+                    static_cast<TemplateLocalViewItem*>(mItemList[i]);
 
-    if (mpDocTemplates->CopyFrom(nRegionId,nId,aPath))
-    {
-        TemplateItemProperties aTemplate;
-        aTemplate.nId = nId+1;
-        aTemplate.nDocId = nId;
-        aTemplate.nRegionId = nRegionId;
-        aTemplate.aName = aPath;
-        aTemplate.aThumbnail = rThumbnail;
-        aTemplate.aPath = mpDocTemplates->GetPath(nRegionId,nId);
-        aTemplate.aType = SvFileInformationManager::GetDescription(INetURLObject(aPath));
+            if (!pRegionItem->maTemplates.empty())
+            {
+                nId = (pRegionItem->maTemplates.back()).nId+1;
+                nDocId = (pRegionItem->maTemplates.back()).nDocId+1;
+            }
 
-        for (size_t i = 0, n = mItemList.size(); i < n; ++i)
-        {
-            if (mItemList[i]->mnId == nRegionItemId)
+            String aPath(rPath);
+
+            if (mpDocTemplates->CopyFrom(nRegionId,nDocId,aPath))
             {
+                TemplateItemProperties aTemplate;
+                aTemplate.nId = nId;
+                aTemplate.nDocId = nDocId;
+                aTemplate.nRegionId = nRegionId;
+                aTemplate.aName = aPath;
+                aTemplate.aThumbnail = rThumbnail;
+                aTemplate.aPath = mpDocTemplates->GetPath(nRegionId,nDocId);
+                aTemplate.aType = SvFileInformationManager::GetDescription(INetURLObject(aTemplate.aPath));
+
                 TemplateLocalViewItem *pItem =
                         static_cast<TemplateLocalViewItem*>(mItemList[i]);
 
@@ -561,26 +569,30 @@ void TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
 
                 lcl_updateThumbnails(pItem);
             }
-        }
 
-        CalculateItemPositions();
+            break;
+        }
     }
 }
 
 void TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const rtl::OUString &rPath)
 {
     sal_uInt16 nId = 0;
+    sal_uInt16 nDocId = 0;
     sal_uInt16 nRegionId = pItem->mnId - 1;
     String aPath(rPath);
 
-    if (!mItemList.empty())
-        nId = (mItemList.back())->mnId+1;
+    if (!pItem->maTemplates.empty())
+    {
+        nId = (pItem->maTemplates.back()).nId+1;
+        nDocId = (pItem->maTemplates.back()).nDocId+1;
+    }
 
-    if (mpDocTemplates->CopyFrom(nRegionId,nId,aPath))
+    if (mpDocTemplates->CopyFrom(nRegionId,nDocId,aPath))
     {
         TemplateItemProperties aTemplate;
-        aTemplate.nId = nId+1;
-        aTemplate.nDocId = nId;
+        aTemplate.nId = nId;
+        aTemplate.nDocId = nDocId;
         aTemplate.nRegionId = nRegionId;
         aTemplate.aName = aPath;
         aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath,
commit 5b5c81be22c2b9a1097ac48dfd9e015c141f729d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Fri Aug 10 20:31:50 2012 -0430

    Set template name when importing.
    
    Change-Id: I81a3ee2a8052079e95cc5a929757b06c289ba4e1

diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 7049a94..78484ba 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -582,7 +582,7 @@ void TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const rtl::OUStr
         aTemplate.nId = nId+1;
         aTemplate.nDocId = nId;
         aTemplate.nRegionId = nRegionId;
-        aTemplate.aName = mpDocTemplates->GetName(nRegionId,nId);
+        aTemplate.aName = aPath;
         aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath,
                                                                     THUMBNAIL_MAX_WIDTH,
                                                                     THUMBNAIL_MAX_HEIGHT);
commit 4364513def9252cd57fac2585c72ba6ee6bf7248
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Fri Aug 10 20:28:40 2012 -0430

    Delete template based on its document id.
    
    - Update all document ids of the templates after it.
    
    Change-Id: I2ffc73882816360a03b8147c6ad24f8d87492ad7

diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 63a6739..7049a94 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -311,26 +311,28 @@ bool TemplateLocalView::removeRegion(const sal_uInt16 nItemId)
 bool TemplateLocalView::removeTemplate (const sal_uInt16 nItemId, const sal_uInt16 nSrcItemId)
 {
     sal_uInt16 nRegionId = nSrcItemId - 1;
-    sal_uInt16 nTemplateId = nItemId - 1;
-
-    if (!mpDocTemplates->Delete(nRegionId,nTemplateId))
-        return false;
 
     for (size_t i = 0, n = mItemList.size(); i < n; ++i)
     {
         if (mItemList[i]->mnId == nSrcItemId)
         {
-
             TemplateLocalViewItem *pItem = static_cast<TemplateLocalViewItem*>(mItemList[i]);
             std::vector<TemplateItemProperties>::iterator pIter;
             for (pIter = pItem->maTemplates.begin(); pIter != pItem->maTemplates.end(); ++pIter)
             {
                 if (pIter->nId == nItemId)
                 {
-                    pItem->maTemplates.erase(pIter);
+                    if (!mpDocTemplates->Delete(nRegionId,pIter->nDocId))
+                        return false;
+
+                    pIter = pItem->maTemplates.erase(pIter);
 
                     mpItemView->RemoveItem(nItemId);
 
+                    // Update Doc Idx for all templates that follow
+                    for (; pIter != pItem->maTemplates.end(); ++pIter)
+                        pIter->nDocId = pIter->nDocId - 1;
+
                     break;
                 }
             }
commit cacba91215f22dad6ddaa055700f40da5b8e8811
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Fri Aug 10 20:04:29 2012 -0430

    Add an index for tracking SfxDocumentTemplate item.
    
    Change-Id: I7d1672e48ef638ac537e5675ed27b67376666d59

diff --git a/sfx2/inc/sfx2/templateproperties.hxx b/sfx2/inc/sfx2/templateproperties.hxx
index 8891ee9..ffa9003 100644
--- a/sfx2/inc/sfx2/templateproperties.hxx
+++ b/sfx2/inc/sfx2/templateproperties.hxx
@@ -15,7 +15,8 @@
 
 struct TemplateItemProperties
 {
-    sal_uInt16 nId;
+    sal_uInt16 nId;         ///< Index for ThumbnailView
+    sal_uInt16 nDocId;      ///< Index based on SfxTemplateDocument
     sal_uInt16 nRegionId;
     rtl::OUString aName;
     rtl::OUString aPath;
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index a1dd938..63a6739 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -154,6 +154,7 @@ void TemplateLocalView::Populate ()
 
             TemplateItemProperties aProperties;;
             aProperties.nId = j+1;
+            aProperties.nDocId = j;
             aProperties.nRegionId = i;
             aProperties.aName = aName;
             aProperties.aPath = aURL;
@@ -384,6 +385,7 @@ bool TemplateLocalView::moveTemplate (const ThumbnailViewItem *pItem, const sal_
 
         TemplateItemProperties aTemplateItem;
         aTemplateItem.nId = nTargetIdx + 1;
+        aTemplateItem.nDocId = nTargetIdx;
         aTemplateItem.nRegionId = nTargetRegion;
         aTemplateItem.aName = pViewItem->maTitle;
         aTemplateItem.aPath = pViewItem->getPath();
@@ -478,6 +480,7 @@ bool TemplateLocalView::moveTemplates(std::set<const ThumbnailViewItem *> &rItem
 
             TemplateItemProperties aTemplateItem;
             aTemplateItem.nId = nTargetIdx + 1;
+            aTemplateItem.nDocId = nTargetIdx;
             aTemplateItem.nRegionId = nTargetRegion;
             aTemplateItem.aName = pViewItem->maTitle;
             aTemplateItem.aPath = pViewItem->getPath();
@@ -538,6 +541,7 @@ void TemplateLocalView::copyFrom(const sal_uInt16 nRegionItemId, const BitmapEx
     {
         TemplateItemProperties aTemplate;
         aTemplate.nId = nId+1;
+        aTemplate.nDocId = nId;
         aTemplate.nRegionId = nRegionId;
         aTemplate.aName = aPath;
         aTemplate.aThumbnail = rThumbnail;
@@ -574,6 +578,7 @@ void TemplateLocalView::copyFrom (TemplateLocalViewItem *pItem, const rtl::OUStr
     {
         TemplateItemProperties aTemplate;
         aTemplate.nId = nId+1;
+        aTemplate.nDocId = nId;
         aTemplate.nRegionId = nRegionId;
         aTemplate.aName = mpDocTemplates->GetName(nRegionId,nId);
         aTemplate.aThumbnail = TemplateAbstractView::fetchThumbnail(rPath,


More information about the Libreoffice-commits mailing list