[Libreoffice-commits] .: Branch 'feature/template-dialog' - 9 commits - icon-themes/galaxy sfx2/inc sfx2/Library_sfx.mk sfx2/source

Rafael Dominguez rdominguez at kemper.freedesktop.org
Wed Jul 4 07:42:03 PDT 2012


 icon-themes/galaxy/sfx2/res/create_draw.png    |binary
 icon-themes/galaxy/sfx2/res/create_present.png |binary
 icon-themes/galaxy/sfx2/res/create_sheet.png   |binary
 icon-themes/galaxy/sfx2/res/create_text.png    |binary
 icon-themes/galaxy/sfx2/res/exec_action.png    |binary
 icon-themes/galaxy/sfx2/res/import.png         |binary
 icon-themes/galaxy/sfx2/res/search.png         |binary
 icon-themes/galaxy/sfx2/res/sortascending.png  |binary
 sfx2/Library_sfx.mk                            |    2 
 sfx2/inc/sfx2/templatefolderview.hxx           |    3 
 sfx2/inc/sfx2/templateview.hxx                 |    1 
 sfx2/inc/templatedlg.hxx                       |    5 +
 sfx2/source/control/templatefolderview.cxx     |   25 +++++
 sfx2/source/control/templatesearchview.cxx     |   56 ++++++++++++
 sfx2/source/control/templateview.cxx           |   48 +++++++----
 sfx2/source/dialog/inputdlg.cxx                |   58 +++++++++++++
 sfx2/source/dialog/inputdlg.hrc                |    7 +
 sfx2/source/dialog/inputdlg.src                |   10 ++
 sfx2/source/doc/templatedlg.cxx                |  108 +++++++++++++++++++++++--
 sfx2/source/doc/templatedlg.hrc                |    6 +
 sfx2/source/doc/templatedlg.src                |   68 +++++++++++++++
 sfx2/source/inc/inputdlg.hxx                   |   37 ++++++++
 sfx2/source/inc/templatesearchview.hxx         |   30 ++++++
 23 files changed, 442 insertions(+), 22 deletions(-)

New commits:
commit 1ceca7ac90cfc6d07ff0bd1357c640180c900553
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jul 4 10:09:40 2012 -0430

    Fetch and display templates that contains the search keyword.
    
    Change-Id: I248bcf7fb1a0248fdbb1cd4e57c815b3d5d0b28b

diff --git a/sfx2/inc/sfx2/templatefolderview.hxx b/sfx2/inc/sfx2/templatefolderview.hxx
index b1dcade..1e0c2b5 100644
--- a/sfx2/inc/sfx2/templatefolderview.hxx
+++ b/sfx2/inc/sfx2/templatefolderview.hxx
@@ -49,6 +49,9 @@ public:
 
     void filterTemplatesByApp (const FILTER_APPLICATION &eApp);
 
+    std::vector<std::pair<sal_uInt16,std::vector<ThumbnailViewItem*> > >
+        getFilteredItems (const boost::function<bool (const ThumbnailViewItem*) > &rFunc) const;
+
     void sortOverlayItems (const boost::function<bool (const ThumbnailViewItem*,
                                                        const ThumbnailViewItem*) > &func);
 
diff --git a/sfx2/source/control/templatefolderview.cxx b/sfx2/source/control/templatefolderview.cxx
index e8b01f5..d202293 100644
--- a/sfx2/source/control/templatefolderview.cxx
+++ b/sfx2/source/control/templatefolderview.cxx
@@ -394,6 +394,31 @@ void TemplateFolderView::filterTemplatesByApp (const FILTER_APPLICATION &eApp)
     }
 }
 
+std::vector<std::pair<sal_uInt16,std::vector<ThumbnailViewItem*> > >
+TemplateFolderView::getFilteredItems(const boost::function<bool (const ThumbnailViewItem*) > &rFunc) const
+{
+    std::vector<ThumbnailViewItem*> aRegionItems;
+    std::vector<std::pair<sal_uInt16,std::vector<ThumbnailViewItem*> > > aItems;
+
+    for (size_t i = 0; i < mItemList.size(); ++i)
+    {
+        TemplateFolderViewItem *pFolderItem = static_cast<TemplateFolderViewItem*>(mItemList[i]);
+
+        sal_uInt16 nRegionId = pFolderItem->mnId-1;
+
+        for (size_t j = 0; j < pFolderItem->maTemplates.size(); ++j)
+        {
+            if (rFunc(pFolderItem->maTemplates[j]))
+                aRegionItems.push_back(pFolderItem->maTemplates[j]);
+        }
+
+        aItems.push_back(std::make_pair(nRegionId,aRegionItems));
+        aRegionItems.clear();
+    }
+
+    return aItems;
+}
+
 void TemplateFolderView::sortOverlayItems(const boost::function<bool (const ThumbnailViewItem*,
                                                                       const ThumbnailViewItem*) > &func)
 {
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
index dbcf0d1..fa6eabc 100644
--- a/sfx2/source/control/templatesearchview.cxx
+++ b/sfx2/source/control/templatesearchview.cxx
@@ -47,6 +47,8 @@ void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sa
     pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected));
 
     mItemList.push_back(pItem);
+
+    CalculateItemPositions();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 13db34c..7f86129 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -64,6 +64,24 @@ public:
     }
 };
 
+class SearchView_Keyword
+{
+public:
+
+    SearchView_Keyword (const rtl::OUString &rKeyword)
+        : maKeyword(rKeyword)
+    {}
+
+    bool operator() (const ThumbnailViewItem *pItem)
+    {
+        return pItem->maText.indexOf(maKeyword) != -1;
+    }
+
+private:
+
+    rtl::OUString maKeyword;
+};
+
 SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     : ModalDialog(parent, SfxResId(DLG_TEMPLATE_MANAGER)),
       aButtonAll(this,SfxResId(BTN_SELECT_ALL)),
@@ -523,11 +541,40 @@ IMPL_LINK (SfxTemplateManagerDlg, SearchUpdateHdl, Edit*, pEdit)
     // if the search view is hidden, hide the folder view and display search one
     if (!mpSearchView->IsVisible())
     {
+        mpSearchView->Clear();
         mpSearchView->Show();
         maView->Hide();
     }
 
-    mpSearchView->Clear();
+    rtl::OUString aKeyword = mpSearchEdit->GetText();
+
+    if (!aKeyword.isEmpty())
+    {
+        mpSearchView->Clear();
+
+        std::vector<std::pair<sal_uInt16,std::vector<ThumbnailViewItem*> > > aItems =
+                maView->getFilteredItems(SearchView_Keyword(aKeyword));
+
+        size_t nCounter = 0;
+        for (size_t i = 0; i < aItems.size(); ++i)
+        {
+            sal_uInt16 nRegionId = aItems[i].first;
+            std::vector<ThumbnailViewItem*> &rRegionItems = aItems[i].second;
+
+            for (size_t j = 0; j < rRegionItems.size(); ++j)
+            {
+                TemplateViewItem *pItem = static_cast<TemplateViewItem*>(rRegionItems[j]);
+
+                mpSearchView->AppendItem(++nCounter,nRegionId,
+                                         pItem->mnId-1,
+                                         pItem->maText,
+                                         pItem->getPath(),
+                                         pItem->maPreview1);
+            }
+        }
+
+        mpSearchView->Invalidate();
+    }
 
     return 0;
 }
commit 822532024d078685ab6baa59673d46645dde74de
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jul 4 09:46:29 2012 -0430

    Set search view size an position.
    
    Change-Id: Ifed9e633ef73c4248fa67adc8b0e90dd2c484dbd

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 927dff6..13db34c 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -170,6 +170,13 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     maView->setTemplateStateHdl(LINK(this,SfxTemplateManagerDlg,TVTemplateStateHdl));
     maView->setOverlayDblClickHdl(LINK(this,SfxTemplateManagerDlg,OpenTemplateHdl));
 
+    mpSearchView->SetSizePixel(aThumbSize);
+    mpSearchView->setItemMaxTextLength(ITEM_MAX_TEXT_LENGTH);
+
+    mpSearchView->setItemDimensions(ITEM_MAX_WIDTH,THUMBNAIL_MAX_HEIGHT,
+                                    ITEM_MAX_HEIGHT-THUMBNAIL_MAX_HEIGHT,
+                                    ITEM_PADDING);
+
     // Set OK button position
     Point aBtnPos;
     Size aBtnSize = maButtonClose.GetSizePixel();
@@ -626,6 +633,7 @@ void SfxTemplateManagerDlg::OnTemplateSearch ()
 
     SetSizePixel(aWinSize);
     maView->SetPosPixel(aPos);
+    mpSearchView->SetPosPixel(aPos);
     maButtonClose.SetPosPixel(aClosePos);
 
     // Hide search view
commit c11eff1e28f462ee2371fa9283cd9baa5cb8e5e9
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jul 4 09:03:59 2012 -0430

    Dont cache search term when you finish searching.
    
    Change-Id: I2975bd530dc2377d8b2e0003f9a5c5986d270d6a

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 018e98d..927dff6 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -636,6 +636,7 @@ void SfxTemplateManagerDlg::OnTemplateSearch ()
     }
 
     mpSearchEdit->Show(!bVisible);
+    mpSearchEdit->SetText(rtl::OUString());
 }
 
 void SfxTemplateManagerDlg::OnTemplateEdit ()
commit 74780aa9a984df9d8556abc9a299ece4dbedb0d1
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Jul 4 08:53:29 2012 -0430

    Create a view to display search results.
    
    Change-Id: I85b34937a91dbc321ff98ee873f9e8b9cc037fd2

diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index da80159..1b2944b 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -152,6 +152,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/control/templateviewitem \
     sfx2/source/control/templatefolderview \
     sfx2/source/control/templatefolderviewitem \
+    sfx2/source/control/templatesearchview \
     sfx2/source/control/thumbnailviewitem \
     sfx2/source/control/thumbnailviewacc \
     sfx2/source/control/thumbnailview \
diff --git a/sfx2/inc/templatedlg.hxx b/sfx2/inc/templatedlg.hxx
index f729b6e..3698381 100644
--- a/sfx2/inc/templatedlg.hxx
+++ b/sfx2/inc/templatedlg.hxx
@@ -18,6 +18,8 @@
 class Edit;
 class PopupMenu;
 class TemplateFolderView;
+class TemplateSearchView;
+class ThumbnailView;
 class ThumbnailViewItem;
 class ToolBox;
 
@@ -62,6 +64,8 @@ private:
 
     DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*);
 
+    DECL_LINK(SearchUpdateHdl, Edit*);
+
     void OnTemplateImport ();
     void OnTemplateSearch ();
     void OnTemplateEdit ();
@@ -83,6 +87,7 @@ private:
     ToolBox *mpViewBar;
     ToolBox *mpActionBar;
     ToolBox *mpTemplateBar;
+    TemplateSearchView *mpSearchView;
     TemplateFolderView *maView;
     PopupMenu *mpCreateMenu;
     PopupMenu *mpActionMenu;
diff --git a/sfx2/source/control/templatesearchview.cxx b/sfx2/source/control/templatesearchview.cxx
new file mode 100644
index 0000000..dbcf0d1
--- /dev/null
+++ b/sfx2/source/control/templatesearchview.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "templatesearchview.hxx"
+
+#include <sfx2/templateviewitem.hxx>
+
+struct TemplateSearchViewItem : public TemplateViewItem
+{
+    TemplateSearchViewItem (ThumbnailView &rView, Window *pParent)
+        : TemplateViewItem(rView,pParent)
+    {}
+
+    virtual ~TemplateSearchViewItem ()
+    {}
+
+    sal_uInt16 mnIdx;       // Template associated Index
+    sal_uInt16 mnRegionId;  // Template associated Region id
+};
+
+TemplateSearchView::TemplateSearchView (Window *pParent, WinBits nWinStyle)
+    : ThumbnailView(pParent,nWinStyle)
+{
+}
+
+TemplateSearchView::~TemplateSearchView ()
+{
+}
+
+void TemplateSearchView::AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
+                                    const rtl::OUString &rStr, const rtl::OUString &rPath,
+                                    const BitmapEx &rImage)
+{
+    TemplateSearchViewItem *pItem = new TemplateSearchViewItem(*this,this);
+    pItem->mnId = nItemId;
+    pItem->mnIdx = nIdx;
+    pItem->mnRegionId = nRegionId;
+    pItem->maPreview1 = rImage;
+    pItem->maText = rStr;
+    pItem->setPath(rPath);
+    pItem->setSelectClickHdl(LINK(this,ThumbnailView,OnFolderSelected));
+
+    mItemList.push_back(pItem);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 357c247..018e98d 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -10,6 +10,7 @@
 #include "templatedlg.hxx"
 
 #include "inputdlg.hxx"
+#include "templatesearchview.hxx"
 
 #include <comphelper/processfactory.hxx>
 #include <sfx2/filedlghelper.hxx>
@@ -76,6 +77,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
       mpViewBar( new ToolBox(this, SfxResId(TBX_ACTION_VIEW))),
       mpActionBar( new ToolBox(this, SfxResId(TBX_ACTION_ACTION))),
       mpTemplateBar( new ToolBox(this, SfxResId(TBX_ACTION_TEMPLATES))),
+      mpSearchView(new TemplateSearchView(this)),
       maView(new TemplateFolderView(this,SfxResId(TEMPLATE_VIEW))),
       mnSelectionCount(0),
       mxDesktop(comphelper::getProcessServiceFactory()->createInstance( "com.sun.star.frame.Desktop" ),uno::UNO_QUERY )
@@ -152,6 +154,8 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
 
     mpSearchEdit->SetSizePixel(aSearchSize);
     mpSearchEdit->SetPosPixel(Point(PADDING_DLG_BORDER,aActionPos.Y()+aActionSize.getHeight()));
+    mpSearchEdit->SetUpdateDataHdl(LINK(this,SfxTemplateManagerDlg,SearchUpdateHdl));
+    mpSearchEdit->EnableUpdateData();
 
     maView->SetStyle(WB_VSCROLL);
     maView->SetColor(GetBackground().GetColor());
@@ -507,6 +511,20 @@ IMPL_LINK(SfxTemplateManagerDlg, OpenTemplateHdl, ThumbnailViewItem*, pItem)
     return 0;
 }
 
+IMPL_LINK (SfxTemplateManagerDlg, SearchUpdateHdl, Edit*, pEdit)
+{
+    // if the search view is hidden, hide the folder view and display search one
+    if (!mpSearchView->IsVisible())
+    {
+        mpSearchView->Show();
+        maView->Hide();
+    }
+
+    mpSearchView->Clear();
+
+    return 0;
+}
+
 void SfxTemplateManagerDlg::OnTemplateImport ()
 {
     sal_Int16 nDialogType =
@@ -609,6 +627,14 @@ void SfxTemplateManagerDlg::OnTemplateSearch ()
     SetSizePixel(aWinSize);
     maView->SetPosPixel(aPos);
     maButtonClose.SetPosPixel(aClosePos);
+
+    // Hide search view
+    if (bVisible)
+    {
+        mpSearchView->Hide();
+        maView->Show();
+    }
+
     mpSearchEdit->Show(!bVisible);
 }
 
diff --git a/sfx2/source/inc/templatesearchview.hxx b/sfx2/source/inc/templatesearchview.hxx
new file mode 100644
index 0000000..3d453b3
--- /dev/null
+++ b/sfx2/source/inc/templatesearchview.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __SFX2_TEMPLATESEARCHVIEW_HXX__
+#define __SFX2_TEMPLATESEARCHVIEW_HXX__
+
+#include <sfx2/thumbnailview.hxx>
+
+class TemplateSearchView : public ThumbnailView
+{
+public:
+
+    TemplateSearchView ( Window* pParent, WinBits nWinStyle = WB_TABSTOP | WB_VSCROLL);
+
+    virtual ~TemplateSearchView();
+
+    void AppendItem(sal_uInt16 nItemId, sal_uInt16 nRegionId, sal_uInt16 nIdx,
+                    const rtl::OUString &rStr, const rtl::OUString &rPath,
+                    const BitmapEx &rImage );
+};
+
+#endif // __SFX2_TEMPLATESEARCHVIEW_HXX__
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 89cb69a018568029be04663361ea5813870b3d95
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Jul 3 14:20:19 2012 -0430

    Dont draw folder name while we are editing it.
    
    Change-Id: I9bec6832725b2a5e194968d938de1dac875a59f0

diff --git a/sfx2/inc/sfx2/templateview.hxx b/sfx2/inc/sfx2/templateview.hxx
index 3ecdc9b..8934b58 100644
--- a/sfx2/inc/sfx2/templateview.hxx
+++ b/sfx2/inc/sfx2/templateview.hxx
@@ -56,6 +56,7 @@ protected:
 private:
 
     Image maCloseImg;
+    bool mbRenderTitle;
     sal_uInt16 mnRegionId;
     rtl::OUString maFolderName;
     SfxDocumentTemplates *mpDocTemplates;
diff --git a/sfx2/source/control/templateview.cxx b/sfx2/source/control/templateview.cxx
index 5078fbd..d9748f5 100644
--- a/sfx2/source/control/templateview.cxx
+++ b/sfx2/source/control/templateview.cxx
@@ -36,6 +36,7 @@ using namespace drawinglayer::primitive2d;
 TemplateView::TemplateView (Window *pParent, SfxDocumentTemplates *pTemplates)
     : ThumbnailView(pParent,WB_VSCROLL),
       maCloseImg(SfxResId(IMG_TEMPLATE_VIEW_CLOSE)),
+      mbRenderTitle(true),
       mnRegionId(0),
       mpDocTemplates(pTemplates),
       mpEditName(new Edit(this, WB_BORDER | WB_HIDE))
@@ -60,27 +61,36 @@ void TemplateView::Paint (const Rectangle &rRect)
 {
     ThumbnailView::Paint(rRect);
 
-    Primitive2DSequence aSeq(2);
+    int nCount = 0;
+    int nMaxCount = 1;
+
+    if (mbRenderTitle)
+        ++nMaxCount;
+
+    Primitive2DSequence aSeq(nMaxCount);
     TextLayouterDevice aTextDev;
 
     // Draw centered region name
     Point aPos;
     Size aWinSize = GetOutputSizePixel();
 
-    aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maFolderName,0,maFolderName.getLength()))/2;
-    aPos.Y() = aTextDev.getTextHeight() + (mnHeaderHeight - aTextDev.getTextHeight())/2;
-
-    basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
-                mpItemAttrs->aFontSize.getX(), mpItemAttrs->aFontSize.getY(),
-                double( aPos.X() ), double( aPos.Y() ) ) );
-
-    aSeq[0] = Primitive2DReference(
-                new TextSimplePortionPrimitive2D(aTextMatrix,
-                                                 maFolderName,0,maFolderName.getLength(),
-                                                 std::vector< double >( ),
-                                                 mpItemAttrs->aFontAttr,
-                                                 com::sun::star::lang::Locale(),
-                                                 Color(COL_BLACK).getBColor() ) );
+    if (mbRenderTitle)
+    {
+        aPos.X() = (aWinSize.getWidth() - aTextDev.getTextWidth(maFolderName,0,maFolderName.getLength()))/2;
+        aPos.Y() = aTextDev.getTextHeight() + (mnHeaderHeight - aTextDev.getTextHeight())/2;
+
+        basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
+                    mpItemAttrs->aFontSize.getX(), mpItemAttrs->aFontSize.getY(),
+                    double( aPos.X() ), double( aPos.Y() ) ) );
+
+        aSeq[nCount++] = Primitive2DReference(
+                    new TextSimplePortionPrimitive2D(aTextMatrix,
+                                                     maFolderName,0,maFolderName.getLength(),
+                                                     std::vector< double >( ),
+                                                     mpItemAttrs->aFontAttr,
+                                                     com::sun::star::lang::Locale(),
+                                                     Color(COL_BLACK).getBColor() ) );
+    }
 
     // Draw close icon
     Size aImageSize = maCloseImg.GetSizePixel();
@@ -88,7 +98,7 @@ void TemplateView::Paint (const Rectangle &rRect)
     aPos.Y() = (mnHeaderHeight - aImageSize.Height())/2;
     aPos.X() = aWinSize.Width() - aImageSize.Width() - aPos.Y();
 
-    aSeq[1] = Primitive2DReference( new FillBitmapPrimitive2D(
+    aSeq[nCount] = Primitive2DReference( new FillBitmapPrimitive2D(
                                         createTranslateB2DHomMatrix(aPos.X(),aPos.Y()),
                                         FillBitmapAttribute(maCloseImg.GetBitmapEx(),
                                                             B2DPoint(0,0),
@@ -161,6 +171,7 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt)
         if (mpEditName->IsVisible())
         {
             mpEditName->Show(false);
+            mbRenderTitle = true;
 
             // Update name if its not empty
             rtl::OUString aTmp = mpEditName->GetText();
@@ -203,7 +214,12 @@ void TemplateView::MouseButtonDown (const MouseEvent &rMEvt)
             Rectangle aTitleRect(aPos,Size(fTextWidth,aTextDev.getTextHeight()));
 
             if (aTitleRect.IsInside(rMEvt.GetPosPixel()))
+            {
+                mbRenderTitle = false;
+
+                Invalidate();
                 mpEditName->Show();
+            }
         }
     }
 
commit 9f55545a1a1d96e133eb734607ef52a463a0f0ea
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Jul 3 14:06:50 2012 -0430

    Create dialog skeleton to ask user for new folder name.
    
    Change-Id: I5f861753c7b4d0e901c8268f4004676df7da124f

diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 0bff14e..da80159 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -164,6 +164,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/dialog/filedlghelper \
     sfx2/source/dialog/filtergrouping \
     sfx2/source/dialog/itemconnect \
+    sfx2/source/dialog/inputdlg \
     sfx2/source/dialog/mailmodel \
     sfx2/source/dialog/mgetempl \
     sfx2/source/dialog/navigat \
diff --git a/sfx2/source/dialog/inputdlg.cxx b/sfx2/source/dialog/inputdlg.cxx
new file mode 100644
index 0000000..41d5d4f
--- /dev/null
+++ b/sfx2/source/dialog/inputdlg.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "inputdlg.hxx"
+
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+
+#define LABEL_TEXT_SPACE 10
+#define DIALOG_BORDER 10
+#define MAX_FOLDER_NAME_LENGTH 20
+
+InputDialog::InputDialog (const rtl::OUString &rLabelText, Window *pParent)
+    : ModalDialog(pParent),
+      mpEntry(new Edit(this)),
+      mpLabel(new FixedText(this))
+{
+    SetStyle(GetStyle() | WB_CENTER | WB_VCENTER);
+
+    Point aPos(DIALOG_BORDER,DIALOG_BORDER);
+
+    Size aTextSize = mpLabel->CalcMinimumTextSize(mpLabel,100);
+    Size aEntrySize = mpEntry->CalcSize(MAX_FOLDER_NAME_LENGTH);
+
+    aTextSize.setWidth(aEntrySize.getHeight());
+
+    mpLabel->SetPosPixel(Point(DIALOG_BORDER,DIALOG_BORDER));
+    mpLabel->SetSizePixel(aTextSize);
+    mpLabel->SetText(String("Enter name"));
+
+    aPos.setX(DIALOG_BORDER + aTextSize.getWidth() + LABEL_TEXT_SPACE + DIALOG_BORDER);
+
+    mpEntry->SetPosPixel(aPos);
+    mpEntry->SetSizePixel(aEntrySize);
+
+    // Set windows correct size
+    SetSizePixel(Size(aTextSize.getWidth() + aEntrySize.getWidth() + 2*DIALOG_BORDER,
+                      aTextSize.getHeight()+2*DIALOG_BORDER));
+
+    mpEntry->Show();
+    mpLabel->Show();
+}
+
+rtl::OUString InputDialog::getEntryText () const
+{
+    return mpEntry->GetText();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+
+
diff --git a/sfx2/source/dialog/inputdlg.hrc b/sfx2/source/dialog/inputdlg.hrc
new file mode 100644
index 0000000..b9fdf70
--- /dev/null
+++ b/sfx2/source/dialog/inputdlg.hrc
@@ -0,0 +1,7 @@
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
diff --git a/sfx2/source/dialog/inputdlg.src b/sfx2/source/dialog/inputdlg.src
new file mode 100644
index 0000000..cece9f8
--- /dev/null
+++ b/sfx2/source/dialog/inputdlg.src
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "inputdlg.hrc"
+
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 9b819ba..357c247 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -9,6 +9,8 @@
 
 #include "templatedlg.hxx"
 
+#include "inputdlg.hxx"
+
 #include <comphelper/processfactory.hxx>
 #include <sfx2/filedlghelper.hxx>
 #include <sfx2/sfxresid.hxx>
@@ -459,6 +461,9 @@ IMPL_LINK(SfxTemplateManagerDlg, MoveMenuSelectHdl, Menu*, pMenu)
 
     if (nMenuId == MNI_MOVE_NEW)
     {
+        InputDialog dlg(SfxResId(STR_INPUT_NEW).toString(),this);
+
+        int ret = dlg.Execute();
     }
     else if (nMenuId == MNI_MOVE_DELETE)
     {
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index b24d844..8a46b11 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -51,6 +51,7 @@
 
 #define STR_MOVE_NEW                268
 #define STR_MOVE_DELETE             270
+#define STR_INPUT_NEW               271
 
 #define IMG_ONLINE_REPOSITORY       100
 #define IMG_CREATE_TEXT             300
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index 27fdfbb..f0ac332 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -45,6 +45,11 @@ String STR_MOVE_DELETE
     Text [ en-US ] = "No folder";
 };
 
+String STR_INPUT_NEW
+{
+    Text [ en-US ] = "Enter folder name:";
+};
+
 ModalDialog DLG_TEMPLATE_MANAGER
 {
     HelpId = CMD_SID_TEMPLATE_MANAGER;
diff --git a/sfx2/source/inc/inputdlg.hxx b/sfx2/source/inc/inputdlg.hxx
new file mode 100644
index 0000000..7e09c9f
--- /dev/null
+++ b/sfx2/source/inc/inputdlg.hxx
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright 2012 LibreOffice contributors.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INPUTDLG_HXX
+#define INPUTDLG_HXX
+
+#include <vcl/dialog.hxx>
+
+class Edit;
+class FixedText;
+class PushButton;
+
+class InputDialog : public ModalDialog
+{
+public:
+
+    InputDialog (const rtl::OUString &labelText, Window *pParent = NULL);
+
+    rtl::OUString getEntryText () const;
+
+private:
+
+    Edit *mpEntry;
+    FixedText *mpLabel;
+    PushButton *mpOK;
+    PushButton *mpCancel;
+};
+
+#endif // INPUTDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ff1ba1fc3c45b7449e2f4fe3c46a1d4c134a7092
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Jul 2 23:13:12 2012 -0430

    Move close button down while search is active.
    
    Change-Id: I42eed0d99b6eae6510c62fda76492e8114624459

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 2483dcb..9b819ba 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -581,6 +581,7 @@ 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();
@@ -589,17 +590,20 @@ 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);
     }
 
     SetSizePixel(aWinSize);
     maView->SetPosPixel(aPos);
+    maButtonClose.SetPosPixel(aClosePos);
     mpSearchEdit->Show(!bVisible);
 }
 
commit 007ad58e5108431b01db5e2aa93fd21b6ca508f2
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Jul 2 22:59:53 2012 -0430

    Add icons to toolbar buttons and menus.
    
    Change-Id: Ia1415d3cab1f381a7b84ad3cabeacefe739a047c

diff --git a/icon-themes/galaxy/sfx2/res/create_draw.png b/icon-themes/galaxy/sfx2/res/create_draw.png
new file mode 100644
index 0000000..f99e503
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/create_draw.png differ
diff --git a/icon-themes/galaxy/sfx2/res/create_present.png b/icon-themes/galaxy/sfx2/res/create_present.png
new file mode 100644
index 0000000..f3e7e26
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/create_present.png differ
diff --git a/icon-themes/galaxy/sfx2/res/create_sheet.png b/icon-themes/galaxy/sfx2/res/create_sheet.png
new file mode 100644
index 0000000..e317659
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/create_sheet.png differ
diff --git a/icon-themes/galaxy/sfx2/res/create_text.png b/icon-themes/galaxy/sfx2/res/create_text.png
new file mode 100644
index 0000000..35bc877
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/create_text.png differ
diff --git a/icon-themes/galaxy/sfx2/res/exec_action.png b/icon-themes/galaxy/sfx2/res/exec_action.png
new file mode 100644
index 0000000..e57abd7
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/exec_action.png differ
diff --git a/icon-themes/galaxy/sfx2/res/import.png b/icon-themes/galaxy/sfx2/res/import.png
new file mode 100644
index 0000000..37f6406
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/import.png differ
diff --git a/icon-themes/galaxy/sfx2/res/search.png b/icon-themes/galaxy/sfx2/res/search.png
new file mode 100644
index 0000000..228d958
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/search.png differ
diff --git a/icon-themes/galaxy/sfx2/res/sortascending.png b/icon-themes/galaxy/sfx2/res/sortascending.png
new file mode 100644
index 0000000..3d710f9
Binary files /dev/null and b/icon-themes/galaxy/sfx2/res/sortascending.png differ
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 4a8322e..2483dcb 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -82,14 +82,14 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
 
     // Create popup menus
     mpCreateMenu = new PopupMenu;
-    mpCreateMenu->InsertItem(MNI_CREATE_TEXT,SfxResId(STR_CREATE_TEXT).toString());
-    mpCreateMenu->InsertItem(MNI_CREATE_SHEET,SfxResId(STR_CREATE_SHEET).toString());
-    mpCreateMenu->InsertItem(MNI_CREATE_PRESENT,SfxResId(STR_CREATE_PRESENT).toString());
-    mpCreateMenu->InsertItem(MNI_CREATE_DRAW,SfxResId(STR_CREATE_DRAW).toString());
+    mpCreateMenu->InsertItem(MNI_CREATE_TEXT,SfxResId(STR_CREATE_TEXT).toString(),SfxResId(IMG_CREATE_TEXT));
+    mpCreateMenu->InsertItem(MNI_CREATE_SHEET,SfxResId(STR_CREATE_SHEET).toString(),SfxResId(IMG_CREATE_SHEET));
+    mpCreateMenu->InsertItem(MNI_CREATE_PRESENT,SfxResId(STR_CREATE_PRESENT).toString(),SfxResId(IMG_CREATE_PRESENT));
+    mpCreateMenu->InsertItem(MNI_CREATE_DRAW,SfxResId(STR_CREATE_DRAW).toString(),SfxResId(IMG_CREATE_DRAW));
     mpCreateMenu->SetSelectHdl(LINK(this, SfxTemplateManagerDlg, MenuSelectHdl));
 
     mpActionMenu = new PopupMenu;
-    mpActionMenu->InsertItem(MNI_ACTION_SORT_NAME,SfxResId(STR_ACTION_SORT_NAME).toString());
+    mpActionMenu->InsertItem(MNI_ACTION_SORT_NAME,SfxResId(STR_ACTION_SORT_NAME).toString(),SfxResId(IMG_ACTION_SORT));
     mpActionMenu->SetSelectHdl(LINK(this,SfxTemplateManagerDlg,MenuSelectHdl));
 
     Size aWinSize = GetOutputSize();
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index 245466f..b24d844 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -53,3 +53,8 @@
 #define STR_MOVE_DELETE             270
 
 #define IMG_ONLINE_REPOSITORY       100
+#define IMG_CREATE_TEXT             300
+#define IMG_CREATE_SHEET            301
+#define IMG_CREATE_PRESENT          302
+#define IMG_CREATE_DRAW             303
+#define IMG_ACTION_SORT             304
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index f4b6962..27fdfbb 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -129,10 +129,51 @@ ModalDialog DLG_TEMPLATE_MANAGER
     {
         ImageBitmap = Bitmap
         {
-            File = "signet.png";
+            File = "ln053.png";
         };
     };
 
+    Image IMG_CREATE_TEXT
+    {
+        ImageBitmap = Bitmap
+        {
+            File = "create_text.png";
+        };
+    };
+
+    Image IMG_CREATE_SHEET
+    {
+        ImageBitmap = Bitmap
+        {
+            File = "create_sheet.png";
+        };
+    };
+
+    Image IMG_CREATE_PRESENT
+    {
+        ImageBitmap = Bitmap
+        {
+            File = "create_present.png";
+        };
+    };
+
+    Image IMG_CREATE_DRAW
+    {
+        ImageBitmap = Bitmap
+        {
+            File = "create_draw.png";
+        };
+    };
+
+    Image IMG_ACTION_SORT
+    {
+        ImageBitmap = Bitmap
+        {
+            File = "sortascending.png";
+        };
+    };
+
+
     ToolBox TBX_ACTION_VIEW
     {
         SVLook = TRUE ;
@@ -145,12 +186,22 @@ ModalDialog DLG_TEMPLATE_MANAGER
             {
                 Identifier = TBI_TEMPLATE_CREATE;
                 Text [ en-US ] = "Create a template" ;
+
+                ItemImage = Image
+                {
+                    ImageBitmap = Bitmap { File = "create_text.png" ; };
+                };
             };
 
             ToolBoxItem
             {
                 Identifier = TBI_TEMPLATE_IMPORT ;
                 Text [ en-US ] = "Import a template" ;
+
+                ItemImage = Image
+                {
+                    ImageBitmap = Bitmap { File = "import.png" ; };
+                };
             };
         };
     };
@@ -167,12 +218,22 @@ ModalDialog DLG_TEMPLATE_MANAGER
             {
                 Identifier = TBI_TEMPLATE_SEARCH;
                 Text [en-US] = "Search";
+
+                ItemImage = Image
+                {
+                    ImageBitmap = Bitmap { File = "search.png" ; };
+                };
             };
 
             ToolBoxItem
             {
                 Identifier = TBI_TEMPLATE_ACTION;
                 Text [en-US] = "Action Menu";
+
+                ItemImage = Image
+                {
+                    ImageBitmap = Bitmap { File = "exec_action.png" ; };
+                };
             };
         };
     };
commit 93a378e081d7311ee43ea4f8f283eed38814ca0e
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Mon Jul 2 21:41:37 2012 -0430

    Disable importing a template while a folder isnt selected.
    
    Change-Id: I3428205cafe41784ee8df24f8511511eebca81c2

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 4488bc9..4a8322e 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -122,6 +122,7 @@ SfxTemplateManagerDlg::SfxTemplateManagerDlg (Window *parent)
     mpTemplateBar->SetButtonType(BUTTON_SYMBOLTEXT);
 
     // Set toolbox button bits
+    mpViewBar->EnableItem(TBI_TEMPLATE_IMPORT,false);
     mpViewBar->SetItemBits(TBI_TEMPLATE_CREATE, TIB_DROPDOWNONLY);
     mpActionBar->SetItemBits(TBI_TEMPLATE_ACTION, TIB_DROPDOWNONLY);
     mpTemplateBar->SetItemBits(TBI_TEMPLATE_MOVE,TIB_DROPDOWNONLY);
@@ -370,11 +371,17 @@ IMPL_LINK(SfxTemplateManagerDlg, TVFolderStateHdl, const ThumbnailViewItem*, pIt
 {
     if (pItem->isSelected())
     {
+        if (maSelFolders.empty())
+            mpViewBar->EnableItem(TBI_TEMPLATE_IMPORT,true);
+
         maSelFolders.insert(pItem);
     }
     else
     {
         maSelFolders.erase(pItem);
+
+        if (maSelFolders.empty())
+            mpViewBar->EnableItem(TBI_TEMPLATE_IMPORT,false);
     }
 
     return 0;


More information about the Libreoffice-commits mailing list