sd/inc/slidehack.hxx                   |   30 ++++---
 sd/source/ui/dlg/GroupSlidesDialog.cxx |  128 ++++++++++++++++++++++++++-------
 sd/source/ui/dlg/GroupSlidesDialog.hxx |   29 ++++++-
 sd/uiconfig/simpress/ui/groupslides.ui |   30 ++++---
 4 files changed, 158 insertions(+), 59 deletions(-)

New commits:
commit b9e6d3cf5544f852e064696dde99dc3152d5038f
Author: Michael Meeks <michael.me...@suse.com>
Date:   Wed Apr 10 20:13:50 2013 +0100

    add lots of un-tested code to the GroupSlidesDialog.
    
    Change-Id: Id4c30f23dbee676f65511204d85bbcb47bc74e1d

diff --git a/sd/source/ui/dlg/GroupSlidesDialog.cxx 
b/sd/source/ui/dlg/GroupSlidesDialog.cxx
index d6c3cb2..0771d5a 100644
--- a/sd/source/ui/dlg/GroupSlidesDialog.cxx
+++ b/sd/source/ui/dlg/GroupSlidesDialog.cxx
@@ -7,55 +7,129 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
 
+#include "slidehack.hxx"
 #include "GroupSlidesDialog.hxx"
 
-#include <com/sun/star/graphic/GraphicProvider.hpp>
-#include <com/sun/star/graphic/XGraphicProvider.hpp>
-#include <comphelper/namedvaluecollection.hxx>
-#include <comphelper/processfactory.hxx>
-#include <comphelper/componentcontext.hxx>
-
-#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
-#include <com/sun/star/drawing/XDrawPages.hpp>
-#include <com/sun/star/drawing/XDrawPage.hpp>
-#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
-
-#include <sfx2/filedlghelper.hxx>
-#include <tools/urlobj.hxx>
-
-#include <unotools/pathoptions.hxx>
-#include <unotools/useroptions.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-
 #include <vcl/msgbox.hxx>
 
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::presentation;
+using namespace ::SlideHack;
 
 namespace sd
 {
 
+namespace {
+    OriginDetailsPtr findLeadOrigin( const std::vector< SdPage * > &rPages )
+    {
+        for( size_t i = 0; i < rPages.size(); i++)
+        {
+            if ( rPages[i]->getOrigin().get() )
+                return rPages[i]->getOrigin();
+        }
+        return OriginDetailsPtr();
+    }
+}
+
+void SdGroupSlidesDialog::addGroupsToCombo( ComboBox *pBox, SdDrawDocument 
*pDoc )
+{
+    mpGroupCombo->Clear();
+
+    sal_uInt32 nPages = pDoc->GetSdPageCount( PK_STANDARD );
+    StorePtr pStore = SlideHack::Store::getStore();
+    OSL_ASSERT( pStore.get() );
+    for ( sal_uInt32 nPage = 0; nPage < nPages; ++nPage )
+    {
+        SdPage *pPage = pDoc->GetSdPage( nPage, PK_STANDARD );
+        OriginDetailsPtr pOrigin = pPage->getOrigin();
+        if ( !pOrigin.get() )
+            continue;
+        GroupPtr pGroup = pStore->lookupGroup( pOrigin );
+        if ( !pGroup.get() )
+            continue;
+        if ( std::find( maGroups.begin(), maGroups.end(), pGroup ) != 
maGroups.end() )
+            continue;
+        maGroups.push_back( pGroup );
+        mpGroupCombo->InsertEntry( pGroup->getMetaData()->getName() );
+    }
+}
+
 SdGroupSlidesDialog::SdGroupSlidesDialog(Window* pWindow, SdDrawDocument* 
pActDoc,
                                          const std::vector< SdPage * > &rPages 
)
-  : ModalDialog(pWindow, "GroupSlidesDialog", 
"modules/simpress/ui/groupslides.ui"),
-    pDoc(pActDoc),
+  : ModalDialog( pWindow, "GroupSlidesDialog", 
"modules/simpress/ui/groupslides.ui" ),
+    mpDoc( pActDoc ),
     maPages( rPages )
 {
-    get(pCancelBtn, "cancel_btn");
-    pCancelBtn->SetClickHdl(LINK(this, SdGroupSlidesDialog, CancelHdl));
+    get( mpAddBtn, "add_btn" );
+    get( mpCancelBtn, "cancel_btn" );
+    get( mpGroupCombo, "cb_group" );
+    get( mpTitle, "ed_title" );
+    get( mpKeywords, "ed_keywords" );
+
+    mpAddBtn->SetClickHdl( LINK( this, SdGroupSlidesDialog, AddHdl ) );
+    mpCancelBtn->SetClickHdl( LINK( this, SdGroupSlidesDialog, CancelHdl ) );
+
+    addGroupsToCombo( mpGroupCombo, mpDoc );
+    mpGroupCombo->SetSelectHdl( LINK( this, SdGroupSlidesDialog, 
GroupSelectHdl ) );
+    mpGroupCombo->SetDoubleClickHdl( LINK( this, SdGroupSlidesDialog, 
GroupDoubleClickHdl ) );
+    mpGroupCombo->EnableAutocomplete( true );
 }
 
 SdGroupSlidesDialog::~SdGroupSlidesDialog()
 {
 }
 
-IMPL_LINK_NOARG(SdGroupSlidesDialog, CancelHdl)
+IMPL_LINK_NOARG(SdGroupSlidesDialog, AddHdl)
 {
+    fprintf(stderr, "Add to group\n");
     EndDialog(0);
     return 0;
 }
 
+int SdGroupSlidesDialog::endDialog( bool bSuccessSoSave )
+{
+    if ( bSuccessSoSave )
+    {
+        sal_uInt16 nSelected = mpGroupCombo->GetSelectEntryPos();
+        fprintf( stderr, "complete: %d\n", (int) nSelected );
+        if ( nSelected < maGroups.size() )
+        {
+            fprintf( stderr, "one selected\n" );
+        }
+        else
+        {
+            fprintf( stderr, "new group\n" );
+        }
+    }
+
+    EndDialog(0);
+
+    return bSuccessSoSave ? 0 : 1;
+}
+
+void SdGroupSlidesDialog::populateEdits( GroupPtr pGroup )
+{
+    mpTitle->SetText( pGroup->getMetaData()->getTopic() );
+    mpKeywords->SetText( "fixme herrings pengins flippers" );
+}
+
+IMPL_LINK_NOARG( SdGroupSlidesDialog, CancelHdl )
+{
+    return endDialog( false ) ;
+}
+
+IMPL_LINK_NOARG( SdGroupSlidesDialog, GroupSelectHdl )
+{
+    sal_uInt16 nSelected = mpGroupCombo->GetSelectEntryPos();
+    OSL_ASSERT( nSelected < maGroups.size() );
+    fprintf( stderr, "select hdl %d\n", (int) nSelected );
+    populateEdits( maGroups[ nSelected ] );
+    return 0;
+}
+
+IMPL_LINK_NOARG( SdGroupSlidesDialog, GroupDoubleClickHdl )
+{
+    GroupSelectHdl( 0 );
+    return endDialog( true ) ;
+}
+
 }
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/GroupSlidesDialog.hxx 
b/sd/source/ui/dlg/GroupSlidesDialog.hxx
index ed5c9c8..bf2ce35 100644
--- a/sd/source/ui/dlg/GroupSlidesDialog.hxx
+++ b/sd/source/ui/dlg/GroupSlidesDialog.hxx
@@ -23,10 +23,17 @@
 #include <vcl/graphicfilter.hxx>
 #include <svx/svdotext.hxx>
 
+#include <slidehack.hxx>
+
 class SdrTextObj;
 class SdDrawDocument;
 class SdPage;
 
+namespace SlideHack {
+    class Group;
+    typedef boost::shared_ptr< class Group > GroupPtr;
+}
+
 namespace sd
 {
 
@@ -38,12 +45,26 @@ public:
     ~SdGroupSlidesDialog();
 
 private:
-    CancelButton*   pCancelBtn;
-
-    SdDrawDocument* pDoc;
+    SdDrawDocument* mpDoc;
     std::vector< SdPage * > maPages;
 
-    DECL_LINK(CancelHdl, void*);
+    CancelButton  *mpCancelBtn;
+    PushButton    *mpAddBtn;
+
+    ComboBox*      mpGroupCombo;
+    std::vector< SlideHack::GroupPtr > maGroups;
+    void addGroupsToCombo( ComboBox *pBox, SdDrawDocument *pDoc );
+
+    Edit          *mpTitle;
+    Edit          *mpKeywords;
+
+    DECL_LINK( AddHdl, void* );
+    DECL_LINK( CancelHdl, void* );
+    DECL_LINK( GroupSelectHdl, void* );
+    DECL_LINK( GroupDoubleClickHdl, void* );
+
+    int  endDialog( bool bSuccessSoSave );
+    void populateEdits( SlideHack::GroupPtr pGroup );
 };
 
 }
diff --git a/sd/uiconfig/simpress/ui/groupslides.ui 
b/sd/uiconfig/simpress/ui/groupslides.ui
index bb209bc..9b87ab2 100644
--- a/sd/uiconfig/simpress/ui/groupslides.ui
+++ b/sd/uiconfig/simpress/ui/groupslides.ui
@@ -19,7 +19,7 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="create_btn">
+              <object class="GtkButton" id="add_btn">
                 <property name="label" translatable="yes">Add to 
group</property>
                 <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
@@ -112,7 +112,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkComboBoxText" id="comboboxtext1">
+                          <object class="GtkComboBoxText" id="cb_group">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
                             <property name="hexpand">True</property>
@@ -139,19 +139,11 @@
                           </packing>
                         </child>
                         <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <placeholder/>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="entry1">
+                          <object class="GtkEntry" id="ed_title">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="invisible_char">●</property>
+                            <property name="placeholder_text">&lt;title for 
your group of slides&gt;</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -161,10 +153,11 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkEntry" id="entry2">
+                          <object class="GtkEntry" id="ed_keywords">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="invisible_char">●</property>
+                            <property name="placeholder_text">&lt;topics and 
keywords for searching&gt;</property>
                           </object>
                           <packing>
                             <property name="left_attach">1</property>
@@ -173,6 +166,15 @@
                             <property name="height">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </object>
                     </child>
                   </object>
@@ -299,7 +301,7 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">create_btn</action-widget>
+      <action-widget response="0">add_btn</action-widget>
       <action-widget response="0">cancel_btn</action-widget>
     </action-widgets>
   </object>
commit 4cccbb7ad4a03f4b944c0eec95d9ae51eaf70ceb
Author: Michael Meeks <michael.me...@suse.com>
Date:   Wed Apr 10 19:09:51 2013 +0100

    kill over-complicated 'alternatives' scheme for now.
    
    Change-Id: I91d60be06a7f5b65575c3044e619859918353690

diff --git a/sd/inc/slidehack.hxx b/sd/inc/slidehack.hxx
index 6ff52b4..70ba47a 100644
--- a/sd/inc/slidehack.hxx
+++ b/sd/inc/slidehack.hxx
@@ -7,6 +7,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#ifndef _SD_SLIDEHACK_HXX
+#define _SD_SLIDEHACK_HXX
+
 /*
  * This API is asynchronous, and will emit its callbacks in the LibreOffice
  * main-thread, ie. it is not necessarily thread-safe, take the solar mutex
@@ -22,6 +25,7 @@
 #  pragma GCC diagnostic ignored "-Wempty-body"
 #endif
 
+#include <vector>
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
 #include <boost/noncopyable.hpp>
@@ -37,6 +41,8 @@
 #include <tools/datetime.hxx>
 #include <vcl/bitmapex.hxx>
 
+class SdPage;
+
 namespace SlideHack {
 
 typedef boost::shared_ptr< class Store > StorePtr;
@@ -44,7 +50,7 @@ typedef boost::shared_ptr< class Group > GroupPtr;
 typedef boost::shared_ptr< class Origin > OriginPtr;
 typedef boost::shared_ptr< class GroupMeta > GroupMetaPtr;
 typedef boost::shared_ptr< class VersionData > VersionDataPtr;
-typedef boost::shared_ptr< class Alternatives > AlternativesPtr;
+typedef boost::shared_ptr< class OriginDetails > OriginDetailsPtr;
 
 /// version history
 class VersionData : public boost::enable_shared_from_this< VersionData >,
@@ -70,7 +76,7 @@ public:
 };
 
 /// Tracking where a single slide came from and some policy around that
-class OriginDetails : Origin
+class OriginDetails : public Origin
 {
 public:
     /// how should we set about updating data from this origin ?
@@ -115,7 +121,7 @@ class Group : public boost::enable_shared_from_this< Group 
>,
 public:
     virtual ~Group() {}
 
-    virtual GroupMeta *getMetaData() = 0;
+    virtual GroupMetaPtr getMetaData() = 0;
 
     /// fetches slide data from the potentially remote store
 
@@ -130,15 +136,6 @@ public:
     boost::signals2::signal< void (const std::vector< VersionDataPtr > &) > 
maVersions;
 };
 
-/// We can have multiple (different length) pitches for the same topic
-class Alternatives : public boost::enable_shared_from_this< Alternatives >,
-                     private boost::noncopyable
-{
-public:
-    virtual ~Alternatives() {}
-    virtual std::vector< GroupPtr > getAlternatives() = 0;
-};
-
 /// Overall factory and store for these guys
 class Store : public boost::enable_shared_from_this< Store >,
               private boost::noncopyable
@@ -151,11 +148,14 @@ public:
     /// cancel a running search
     virtual void  cancelSearch( sal_uInt32 nHandle ) = 0;
     /// search completed signal - always in the main thread
-    boost::signals2::signal< void(sal_uInt32, std::vector< AlternativesPtr >) 
> maSearchCompleted;
+    boost::signals2::signal< void(sal_uInt32, std::vector< GroupPtr >) > 
maSearchCompleted;
 
     /// used to create a group handle from a stored slide, so we can
     /// check for updated versions etc.
-    virtual GroupPtr createGroup( OriginPtr pOrigin ) = 0;
+    virtual GroupPtr lookupGroup( OriginPtr pOrigin ) = 0;
+    virtual GroupPtr createGroup( const OUString &rName,
+                                  const OUString &rKeywords,
+                                  const std::vector< SdPage * > &rPages ) = 0;
 
     /// factory function: to get the root
     static StorePtr getStore();
@@ -163,4 +163,6 @@ public:
 
 }
 
+#endif // _SD_SLIDEHACK_HXX
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to