[Libreoffice-commits] .: 7 commits - sfx2/inc sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Aug 19 21:43:11 PDT 2012


 sfx2/inc/sfx2/templatelocalview.hxx       |    2 
 sfx2/inc/sfx2/thumbnailview.hxx           |    9 -
 sfx2/source/control/templatelocalview.cxx |   26 +++++
 sfx2/source/control/thumbnailview.cxx     |  138 +++++++++++-------------------
 sfx2/source/doc/templatedlg.cxx           |   36 +++++++
 sfx2/source/doc/templatedlg.hrc           |    3 
 sfx2/source/doc/templatedlg.src           |   10 ++
 7 files changed, 127 insertions(+), 97 deletions(-)

New commits:
commit 6b697baf5bbfede880e1564111aa92503e4f3102
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Aug 19 14:08:08 2012 -0430

    Ask user if it wants to overwrite a template
    
    Change-Id: I4e0aa8938ebd197b4b77767b9930a389569ba98d

diff --git a/sfx2/inc/sfx2/templatelocalview.hxx b/sfx2/inc/sfx2/templatelocalview.hxx
index 03c4558..268ca8e 100644
--- a/sfx2/inc/sfx2/templatelocalview.hxx
+++ b/sfx2/inc/sfx2/templatelocalview.hxx
@@ -71,6 +71,8 @@ public:
                          com::sun::star::uno::Reference<com::sun::star::frame::XModel> &rModel,
                          const OUString &rName);
 
+    bool isTemplateNameUnique (const sal_uInt16 nRegionItemId, const OUString &rName) const;
+
 private:
 
     virtual void OnItemDblClicked (ThumbnailViewItem *pRegionItem);
diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index 89704b4..79e382f 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -679,6 +679,29 @@ bool TemplateLocalView::saveTemplateAs(const TemplateLocalViewItem *pDstItem,
     return true;
 }
 
+bool TemplateLocalView::isTemplateNameUnique(const sal_uInt16 nRegionItemId, const OUString &rName) const
+{
+    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->aName == rName)
+                    return false;
+            }
+
+            break;
+        }
+    }
+
+    return true;
+}
+
 void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
 {
     // Fill templates
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 0422e36..fa37e3d 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1156,10 +1156,23 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs()
         if (!aName.isEmpty())
         {
             OUString aFolderList;
+            OUString aQMsg(SfxResId(STR_QMSG_TEMPLATE_OVERWRITE).toString());
+            QueryBox aQueryDlg(this,WB_YES_NO | WB_DEF_YES, OUString());
 
             if (maView->isOverlayVisible())
             {
-                if (!maView->saveTemplateAs(maView->getOverlayRegionId()+1,m_xModel,aName))
+                sal_uInt16 nRegionItemId = maView->getOverlayRegionId()+1;
+
+                if (!maView->isTemplateNameUnique(nRegionItemId,aName))
+                {
+                    aQMsg = aQMsg.replaceFirst("$1",aName);
+                    aQueryDlg.SetMessText(aQMsg.replaceFirst("$2",maView->getOverlayName()));
+
+                    if (aQueryDlg.Execute() == RET_NO)
+                        return;
+                }
+
+                if (!maView->saveTemplateAs(nRegionItemId,m_xModel,aName))
                     aFolderList = maView->getOverlayName();
             }
             else
@@ -1168,6 +1181,16 @@ void SfxTemplateManagerDlg::OnTemplateSaveAs()
                 for (pIter = maSelFolders.begin(); pIter != maSelFolders.end(); ++pIter)
                 {
                     TemplateLocalViewItem *pItem = (TemplateLocalViewItem*)(*pIter);
+
+                    if (!maView->isTemplateNameUnique(pItem->mnId,aName))
+                    {
+                        OUString aDQMsg = aQMsg.replaceFirst("$1",aName);
+                        aQueryDlg.SetMessText(aDQMsg.replaceFirst("$2",pItem->maTitle));
+
+                        if (aQueryDlg.Execute() == RET_NO)
+                            continue;
+                    }
+
                     if (!maView->saveTemplateAs(pItem,m_xModel,aName))
                     {
                         if (aFolderList.isEmpty())
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index 5676654..aced42a 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -70,6 +70,7 @@
 #define STR_INPUT_TEMPLATE_NEW              288
 
 #define STR_QMSG_SEL_FOLDER_DELETE          289
+#define STR_QMSG_TEMPLATE_OVERWRITE         290
 
 #define IMG_ACTION_SORT             304
 #define IMG_ACTION_REFRESH          305
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index c0ddde8..4098472 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -95,6 +95,11 @@ String STR_QMSG_SEL_FOLDER_DELETE
     Text [ en-US ] = "Do you want to delete the selected folders?";
 };
 
+String STR_QMSG_TEMPLATE_OVERWRITE
+{
+    Text [ en-US ] = "A template named $1 already exist in $2. Do you want to overwrite it?";
+};
+
 ModelessDialog DLG_TEMPLATE_MANAGER
 {
     OutputSize = TRUE;
commit c0667d15539c0834ef69dda2267ba29084958658
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sun Aug 19 11:09:55 2012 -0430

    Ask user if it wants to delete selected folder.
    
    Change-Id: If878c2a8ffab4c392df9a5171aa206bd23f4cfca

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index e962838..0422e36 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1090,6 +1090,11 @@ void SfxTemplateManagerDlg::OnTemplateAsDefault ()
 
 void SfxTemplateManagerDlg::OnFolderDelete()
 {
+    QueryBox aQueryDlg(this, WB_YES_NO | WB_DEF_YES, SfxResId(STR_QMSG_SEL_FOLDER_DELETE).toString());
+
+    if ( aQueryDlg.Execute() == RET_NO )
+        return;
+
     OUString aFolderList;
 
     std::set<const ThumbnailViewItem*>::const_iterator pIter;
diff --git a/sfx2/source/doc/templatedlg.hrc b/sfx2/source/doc/templatedlg.hrc
index 9871199..5676654 100644
--- a/sfx2/source/doc/templatedlg.hrc
+++ b/sfx2/source/doc/templatedlg.hrc
@@ -69,5 +69,7 @@
 
 #define STR_INPUT_TEMPLATE_NEW              288
 
+#define STR_QMSG_SEL_FOLDER_DELETE          289
+
 #define IMG_ACTION_SORT             304
 #define IMG_ACTION_REFRESH          305
diff --git a/sfx2/source/doc/templatedlg.src b/sfx2/source/doc/templatedlg.src
index db28abc..c0ddde8 100644
--- a/sfx2/source/doc/templatedlg.src
+++ b/sfx2/source/doc/templatedlg.src
@@ -90,6 +90,11 @@ String STR_INPUT_TEMPLATE_NEW
     Text [ en-US ] = "Enter template name:";
 };
 
+String STR_QMSG_SEL_FOLDER_DELETE
+{
+    Text [ en-US ] = "Do you want to delete the selected folders?";
+};
+
 ModelessDialog DLG_TEMPLATE_MANAGER
 {
     OutputSize = TRUE;
commit 6bd26237fddf4aeef091204c7ab52b8b6df90bbc
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 18 11:51:41 2012 -0430

    Hide template export option for remote repositories.
    
    Change-Id: I065e6bb271d4fb646feaaf99a211fedff7edc83c

diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 34e5713..e962838 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -1258,7 +1258,8 @@ void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
 
         mpViewBar->HideItem(TBI_TEMPLATE_FOLDER_DEL);
 
-        // Enable deleting items from the filesystem
+        // Enable deleting and exporting items from the filesystem
+        mpTemplateBar->ShowItem(TBI_TEMPLATE_EXPORT);
         mpTemplateBar->ShowItem(TBI_TEMPLATE_DELETE);
 
         mpOnlineView->Hide();
@@ -1270,7 +1271,8 @@ void SfxTemplateManagerDlg::switchMainView(bool bDisplayLocal)
 
         mpViewBar->ShowItem(TBI_TEMPLATE_FOLDER_DEL);
 
-        // Disable deleting items from remote repositories
+        // Disable deleting and exporting items from remote repositories
+        mpTemplateBar->HideItem(TBI_TEMPLATE_EXPORT);
         mpTemplateBar->HideItem(TBI_TEMPLATE_DELETE);
 
         maView->Hide();
commit e2075f36c27bd3e681c218143d3eb36631ac2e3e
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 18 11:47:26 2012 -0430

    Remove unused functions.
    
    Change-Id: Ie02db475949809254bfb941b6acbf1c887bfd8e5

diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index b2d02e8..6f0978d 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -195,12 +195,8 @@ public:
 
     sal_uInt16 GetItemId( const Point& rPos ) const;
 
-    void SetColCount( sal_uInt16 nNewCols = 1 );
-
     sal_uInt16 GetColCount() const { return mnUserCols; }
 
-    void SetLineCount( sal_uInt16 nNewLines = 0 );
-
     sal_uInt16 GetLineCount() const { return mnUserVisLines; }
 
     long GetItemWidth() const { return mnItemWidth; }
@@ -264,8 +260,6 @@ protected:
 
     virtual void MouseMove( const MouseEvent& rMEvt );
 
-    virtual void Tracking( const TrackingEvent& rMEvt );
-
     virtual void Command( const CommandEvent& rCEvt );
 
     virtual void Paint( const Rectangle& rRect );
@@ -319,10 +313,7 @@ protected:
     SFX2_DLLPRIVATE void         ImplInsertItem( ThumbnailViewItem *const pItem, const size_t nPos );
     SFX2_DLLPRIVATE void            ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue );
     SFX2_DLLPRIVATE bool         ImplHasAccessibleListeners();
-    SFX2_DLLPRIVATE void         ImplTracking( const Point& rPos, bool bRepeat );
-    SFX2_DLLPRIVATE void         ImplEndTracking( const Point& rPos, bool bCancel );
     DECL_DLLPRIVATE_LINK( ImplScrollHdl, ScrollBar* );
-    DECL_DLLPRIVATE_LINK( ImplTimerHdl, void* );
 
     DECL_LINK(OnItemSelected, ThumbnailViewItem*);
 
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index b589ea9..ff1b61e 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -544,27 +544,6 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar )
     return 0;
 }
 
-IMPL_LINK_NOARG(ThumbnailView, ImplTimerHdl)
-{
-    ImplTracking( GetPointerPosPixel(), true );
-    return 0;
-}
-
-void ThumbnailView::ImplTracking( const Point& rPos, bool bRepeat )
-{
-    if ( bRepeat )
-    {
-        if ( ImplScroll( rPos ) )
-        {
-        }
-    }
-}
-
-void ThumbnailView::ImplEndTracking(const Point& /*rPos*/, bool const /*bCancel*/)
-{
-    //FIXME TODO
-}
-
 IMPL_LINK (ThumbnailView, OnItemSelected, ThumbnailViewItem*, pItem)
 {
     maItemStateHdl.Call(pItem);
@@ -683,16 +662,6 @@ void ThumbnailView::MouseMove( const MouseEvent& rMEvt )
     Control::MouseMove( rMEvt );
 }
 
-void ThumbnailView::Tracking( const TrackingEvent& rTEvt )
-{
-    Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
-
-    if ( rTEvt.IsTrackingEnded() )
-        ImplEndTracking( aMousePos, rTEvt.IsTrackingCanceled() );
-    else
-        ImplTracking( aMousePos, rTEvt.IsTrackingRepeat() );
-}
-
 void ThumbnailView::Command( const CommandEvent& rCEvt )
 {
     if ( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
@@ -935,32 +904,6 @@ sal_uInt16 ThumbnailView::GetItemId( const Point& rPos ) const
     return 0;
 }
 
-void ThumbnailView::SetColCount( sal_uInt16 nNewCols )
-{
-    if ( mnUserCols != nNewCols )
-    {
-        mnUserCols = nNewCols;
-
-        CalculateItemPositions();
-
-        if ( IsReallyVisible() && IsUpdateMode() )
-            Invalidate();
-    }
-}
-
-void ThumbnailView::SetLineCount( sal_uInt16 nNewLines )
-{
-    if ( mnUserVisLines != nNewLines )
-    {
-        mnUserVisLines = nNewLines;
-
-        CalculateItemPositions();
-
-        if ( IsReallyVisible() && IsUpdateMode() )
-            Invalidate();
-    }
-}
-
 void ThumbnailView::setItemMaxTextLength(sal_uInt32 nLength)
 {
     mpItemAttrs->nMaxTextLenght = nLength;
commit 1f288cbceda3ebdda719c6f276d249f9333e7b9d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 18 11:39:34 2012 -0430

    Filter overlay with the last selected filter.
    
    Change-Id: I85a7c8837d69e1fc57c03f89f57d78327cd8f9bc

diff --git a/sfx2/source/control/templatelocalview.cxx b/sfx2/source/control/templatelocalview.cxx
index b1d5092..89704b4 100644
--- a/sfx2/source/control/templatelocalview.cxx
+++ b/sfx2/source/control/templatelocalview.cxx
@@ -691,8 +691,7 @@ void TemplateLocalView::OnItemDblClicked (ThumbnailViewItem *pRegionItem)
     if (mbSelectionMode)
         mpItemView->setSelectionMode(true);
 
-    if (meFilterOption != FILTER_APP_NONE)
-        mpItemView->filterItems(ViewFilter_Application(meFilterOption));
+    mpItemView->filterItems(ViewFilter_Application(meFilterOption));
 
     mpItemView->Show();
 }
commit bd4f4acd998fae07695a82ae26bfea19a4adfae0
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Sat Aug 18 11:36:24 2012 -0430

    Set correct scrollbar size depending on the item count of the view.
    
    Change-Id: Ic659f8c3616f43d0e4dd5b4fcc6ec02474c36818

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 996e458..b589ea9 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -395,18 +395,20 @@ void ThumbnailView::CalculateItemPositions ()
     // arrange ScrollBar, set values and show it
     if ( mpScrBar )
     {
+        long nLines = (nCurCount+mnCols-1)/mnCols;
+
         Point aPos( aWinSize.Width() - nScrBarWidth - mnScrBarOffset, mnHeaderHeight );
         Size aSize( nScrBarWidth - mnScrBarOffset, aWinSize.Height() - mnHeaderHeight );
 
         mpScrBar->SetPosSizePixel( aPos, aSize );
-        mpScrBar->SetRangeMax( mnLines );
+        mpScrBar->SetRangeMax( (nCurCount+mnCols-1)/mnCols);
         mpScrBar->SetVisibleSize( mnVisLines );
         mpScrBar->SetThumbPos( (long)mnFirstLine );
         long nPageSize = mnVisLines;
         if ( nPageSize < 1 )
             nPageSize = 1;
         mpScrBar->SetPageSize( nPageSize );
-        mpScrBar->Show(mbScroll);
+        mpScrBar->Show( nLines > mnVisLines );
     }
 
     // delete ScrollBar
@@ -1201,6 +1203,7 @@ void ThumbnailView::setSelectionMode (bool mode)
 
 void ThumbnailView::filterItems (const boost::function<bool (const ThumbnailViewItem*) > &func)
 {
+    mnFirstLine = 0;        // start at the top of the list instead of the current position
     maFilterFunc = func;
 
     CalculateItemPositions();
commit 709a6c1541e53f19a742048ef34ac06b5e7df251
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Aug 15 10:16:09 2012 -0430

    Fix filtering items in thumbnailview when painting.
    
    Change-Id: I2ec3f6d93246b690a5c28305b3173143b53dab35

diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index c9b4a13..996e458 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -322,47 +322,73 @@ void ThumbnailView::CalculateItemPositions ()
     {
         ThumbnailViewItem *const pItem = mItemList[i];
 
-        if ((i >= nFirstItem) && (i < nLastItem) && maFilterFunc(pItem) && nCurCount < nTotalItems)
+        if (maFilterFunc(pItem))
         {
-            if( !pItem->isVisible() && ImplHasAccessibleListeners() )
+            if ((nCurCount >= nFirstItem) && (nCurCount < nLastItem))
             {
-                ::com::sun::star::uno::Any aOldAny, aNewAny;
+                if( !pItem->isVisible())
+                {
+                    if ( ImplHasAccessibleListeners() )
+                    {
+                        ::com::sun::star::uno::Any aOldAny, aNewAny;
 
-                aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
-                ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
-            }
+                        aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                        ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+                    }
+
+                    pItem->show(true);
 
-            if (!mItemList[i]->isVisible())
-                maItemStateHdl.Call(mItemList[i]);
+                    maItemStateHdl.Call(pItem);
+                }
 
-            pItem->show(true);
-            pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
-            pItem->calculateItemsPosition(mnThumbnailHeight,mnDisplayHeight,mnItemPadding,mpItemAttrs->nMaxTextLenght);
+                pItem->setDrawArea(Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ));
+                pItem->calculateItemsPosition(mnThumbnailHeight,mnDisplayHeight,mnItemPadding,mpItemAttrs->nMaxTextLenght);
 
-            if ( !((nCurCount+1) % mnCols) )
-            {
-                x = nStartX;
-                y += mnItemHeight+nVItemSpace;
+                if ( !((nCurCount+1) % mnCols) )
+                {
+                    x = nStartX;
+                    y += mnItemHeight+nVItemSpace;
+                }
+                else
+                    x += mnItemWidth+nHItemSpace;
             }
             else
-                x += mnItemWidth+nHItemSpace;
+            {
+                if( pItem->isVisible())
+                {
+                    if ( ImplHasAccessibleListeners() )
+                    {
+                        ::com::sun::star::uno::Any aOldAny, aNewAny;
+
+                        aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                        ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+                    }
+
+                    pItem->show(false);
+
+                    maItemStateHdl.Call(pItem);
+                }
+
+            }
 
             ++nCurCount;
         }
         else
         {
-            if( pItem->isVisible() && ImplHasAccessibleListeners() )
+            if( pItem->isVisible())
             {
-                ::com::sun::star::uno::Any aOldAny, aNewAny;
+                if ( ImplHasAccessibleListeners() )
+                {
+                    ::com::sun::star::uno::Any aOldAny, aNewAny;
 
-                aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
-                ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
-            }
+                    aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
+                    ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
+                }
 
-            if (mItemList[i]->isVisible())
-                maItemStateHdl.Call(mItemList[i]);
+                pItem->show(false);
 
-            pItem->show(false);
+                maItemStateHdl.Call(pItem);
+            }
         }
     }
 


More information about the Libreoffice-commits mailing list