Rebased ref, commits from common ancestor: commit dacbc71cb3671b84e47019eeafcf92aa55f3dcc1 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 17:01:48 2014 +0200
gtktiledviewer: add part mode selector. Change-Id: Ia1e78df1d833f9b0fbda0b78136590c9c960fa27 diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index d74eb96..a96e1e3 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -151,6 +151,29 @@ void changePart( GtkWidget* pSelector, gpointer /* pItem */ ) lok_docview_set_part( LOK_DOCVIEW(pDocView), nPart ); } } + +void populatePartModeSelector( GtkComboBoxText* pSelector ) +{ + gtk_combo_box_text_append_text( pSelector, "Default" ); + gtk_combo_box_text_append_text( pSelector, "Slide" ); + gtk_combo_box_text_append_text( pSelector, "Notes" ); + gtk_combo_box_text_append_text( pSelector, "Combined (SlideNotes)" ); + gtk_combo_box_text_append_text( pSelector, "Embedded Objects" ); + gtk_combo_box_set_active( GTK_COMBO_BOX(pSelector), 0 ); +} + +void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ ) +{ + // Just convert directly back to the LibreOfficeKitPartMode enum. + // I.e. the ordering above should match the enum member ordering. + LibreOfficeKitPartMode ePartMode = + LibreOfficeKitPartMode( gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) ) ); + + if ( pDocView ) + { + lok_docview_set_partmode( LOK_DOCVIEW(pDocView), ePartMode ); + } +} #endif int main( int argc, char* argv[] ) @@ -207,11 +230,20 @@ int main( int argc, char* argv[] ) gtk_container_add( GTK_CONTAINER(pPartSelectorToolItem), pComboBox ); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartSelectorToolItem, -1 ); g_signal_connect( G_OBJECT(pComboBox), "changed", G_CALLBACK(changePart), NULL ); -#endif GtkToolItem* pSeparator2 = gtk_separator_tool_item_new(); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator2, -1); + GtkToolItem* pPartModeSelectorToolItem = gtk_tool_item_new(); + GtkWidget* pPartModeComboBox = gtk_combo_box_text_new(); + gtk_container_add( GTK_CONTAINER(pPartModeSelectorToolItem), pPartModeComboBox ); + gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pPartModeSelectorToolItem, -1 ); + g_signal_connect( G_OBJECT(pPartModeComboBox), "changed", G_CALLBACK(changePartMode), NULL ); +#endif + + GtkToolItem* pSeparator3 = gtk_separator_tool_item_new(); + gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pSeparator3, -1); + GtkToolItem* pEnableQuadView = gtk_toggle_tool_button_new(); gtk_tool_button_set_label( GTK_TOOL_BUTTON(pEnableQuadView), "Use Quad View" ); gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pEnableQuadView, -1 ); @@ -233,6 +265,7 @@ int main( int argc, char* argv[] ) // GtkComboBox requires gtk 2.24 or later #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 populatePartSelector( GTK_COMBO_BOX_TEXT(pComboBox), LOK_DOCVIEW(pDocView) ); + populatePartModeSelector( GTK_COMBO_BOX_TEXT(pPartModeComboBox) ); #endif gtk_main(); commit 7d0fb0c2707f72cffcc1c2d51956174782a4164d Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 17:01:20 2014 +0200 Protect setPartMode and ensure we actually show the new mode. Change-Id: I3642702c5bf268f3c9ab04162166078052804270 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index e35232d..f12e841 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -510,7 +510,31 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis, return; } - pDoc->setPartMode(ePartMode); + Application::AcquireSolarMutex(1); + { + int nCurrentPart = pDoc->getPart(); + + pDoc->setPartMode(ePartMode); + + // We need to make sure the internal state is updated, just changing the mode + // might not update the relevant shells (i.e. impress will keep rendering the + // previous mode unless we do this). + // TODO: we might want to do this within the relevant components rather than + // here, but that's also dependent on how we implement embedded object + // rendering I guess? + // TODO: we could be clever and e.g. set to 0 when we change to/from + // embedded object mode, and not when changing between slide/notes/combined + // modes? + if ( nCurrentPart < pDoc->getParts() ) + { + pDoc->setPart( nCurrentPart ); + } + else + { + pDoc->setPart( 0 ); + } + } + Application::ReleaseSolarMutex(); } void doc_paintTile (LibreOfficeKitDocument* pThis, commit 817791a1e94de965d5507fabad3f1b8fef1d6bad Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 17:00:56 2014 +0200 Impress/Tiled Rendering: implement setPartMode. Change-Id: I831953ac3fa1d0a15b64aa008cc3bfb79e72575a diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 8fa1904..e620ca5 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -234,6 +234,7 @@ public: virtual int getPart() SAL_OVERRIDE; virtual int getParts() SAL_OVERRIDE; virtual OUString getPartName( int nPart ) SAL_OVERRIDE; + virtual void setPartMode( LibreOfficeKitPartMode ePartMode ) SAL_OVERRIDE; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 7726de4..6c1661b 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2239,7 +2239,6 @@ void SdXImpressDocument::setPart( int nPart ) // only possible to select page 0 in this mode, I have no idea how you // then actually select what is on the handout page, which defaults to // a 4x4 grid of empty pages). - pViewSh->SetPageKind( PK_STANDARD ); pViewSh->SwitchPage( nPart ); } } @@ -2269,6 +2268,40 @@ OUString SdXImpressDocument::getPartName( int nPart ) return pPage->GetName(); } +void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode ) +{ + DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); + if (!pViewSh) + { + return; + } + + PageKind aPageKind; + switch ( ePartMode ) + { + case LOK_PARTMODE_EMBEDDEDOBJ: + // This will probably be handled higher up, i.e. + // we probably shouldn't be handling this here. + // (However we don't offer embedded object-only + // rendering anywhere yet, so this may be a + // completely incorrect comment.) + assert( false ); + // And let's fall through in a normal build. + case LOK_PARTMODE_DEFAULT: + case LOK_PARTMODE_SLIDE: + aPageKind = PK_STANDARD; + break; + case LOK_PARTMODE_SLIDENOTES: + aPageKind = PK_NOTES; + break; + case LOK_PARTMODE_NOTES: + // TODO: this shows combined slides + notes + aPageKind = PK_NOTES; + break; + } + pViewSh->SetPageKind( aPageKind ); +} + Size SdXImpressDocument::getDocumentSize() { SdrPageView* pCurPageView = mpDoc->GetDocSh()->GetViewShell()->GetView()->GetSdrPageView(); commit 18b1fdfb6b250ad1f85bdbc1b4ed126020a07763 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 17:00:33 2014 +0200 LOKDocView: add set_part_mode. Change-Id: I0e14a535124e93979ef05431255911245a11aa29 diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index a73f98d..522d74d 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -64,6 +64,8 @@ void lok_docview_set_part (LOKDocView* pDocView, int nPart); char* lok_docview_get_part_name (LOKDocView* pDocView, int nPart); +void lok_docview_set_partmode (LOKDocView* pDocView, + LibreOfficeKitPartMode ePartMode); #ifdef __cplusplus } #endif diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index 17c0a1c..76faa3b 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -194,4 +194,11 @@ SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int { return pDocView->pDocument->pClass->getPartName( pDocView->pDocument, nPart ); } + +SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView, + LibreOfficeKitPartMode ePartMode ) +{ + pDocView->pDocument->pClass->setPartMode( pDocView->pDocument, ePartMode ); + renderDocument( pDocView ); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit afdbf7dbd95653831ac3edff1eecdc77f85ad873 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 16:59:10 2014 +0200 Impress/Tiled Rendering: return correct number for getPart. It looks like page ids begin with 1. Change-Id: I367285b8cfa1fcc9b8f22a9bb3c679d7e9579099 diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index b6754ec..7726de4 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2256,7 +2256,8 @@ int SdXImpressDocument::getPart() DrawViewShell* pViewSh = dynamic_cast< DrawViewShell* >( mpDoc->GetDocSh()->GetViewShell() ); if (pViewSh) { - return pViewSh->GetCurPageId(); + // curPageId seems to start at 1 + return pViewSh->GetCurPageId() - 1; } return 0; } commit 248f5679783d442479f1e966228c759f0e139b91 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 13:28:49 2014 +0200 ITiledRenderable: provide default implementations for some methods. Writer doesn't understand the concept of parts at the moment, it makes most sense to keep these dummy implementations central. Change-Id: Iafbd89864b753ba2bed28a05b0f59df85f364feb diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index a872713..a57053e 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -47,18 +47,27 @@ public: * Set the document "part", i.e. slide for a slideshow, and * tab for a spreadsheet. */ - virtual void setPart( int nPart ) = 0; + virtual void setPart( int nPart ) + { + (void) nPart; + } /** * Get the number of parts -- see setPart for further details. */ - virtual int getParts() = 0; + virtual int getParts() + { + return 1; + } /** * Get the currently displayed/selected part -- see setPart for further * details. */ - virtual int getPart() = 0; + virtual int getPart() + { + return 0; + } /** * Get the name of the currently displayed part, i.e. sheet in a spreadsheet diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 1318071..a48a8f3 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -439,9 +439,6 @@ public: long nTileWidth, long nTileHeight ) SAL_OVERRIDE; virtual Size getDocumentSize() SAL_OVERRIDE; - virtual void setPart( int nPart ) SAL_OVERRIDE; - virtual int getPart() SAL_OVERRIDE; - virtual int getParts() SAL_OVERRIDE; void Invalidate(); void Reactivate(SwDocShell* pNewDocShell); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 8208814..1dc5f54 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3139,21 +3139,6 @@ Size SwXTextDocument::getDocumentSize() return pViewShell->GetDocSize(); } -void SwXTextDocument::setPart( int /*nPart*/ ) -{ -} - -int SwXTextDocument::getPart() -{ - return 0; -} - -int SwXTextDocument::getParts() -{ - // For now we treat the document as one large piece. - return 1; -} - void * SAL_CALL SwXTextDocument::operator new( size_t t) throw() { return SwXTextDocumentBaseClass::operator new(t); commit 487019b69874904366a08eeca5fb6feffb8021d6 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 13:19:44 2014 +0200 Impress: Implement getPartName. Change-Id: I614838505fef901fc37e8d3906bb59c60b034453 diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index 6887663..8fa1904 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -233,6 +233,7 @@ public: virtual void setPart( int nPart ) SAL_OVERRIDE; virtual int getPart() SAL_OVERRIDE; virtual int getParts() SAL_OVERRIDE; + virtual OUString getPartName( int nPart ) SAL_OVERRIDE; // XComponent diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 5a162f2..b6754ec 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2261,6 +2261,13 @@ int SdXImpressDocument::getPart() return 0; } +OUString SdXImpressDocument::getPartName( int nPart ) +{ + SdPage* pPage = mpDoc->GetSdPage( nPart, PK_STANDARD ); + assert( pPage ); + return pPage->GetName(); +} + Size SdXImpressDocument::getDocumentSize() { SdrPageView* pCurPageView = mpDoc->GetDocSh()->GetViewShell()->GetView()->GetSdrPageView(); commit 90bb3e457d36343ff951d7305fdb7ed51fe33223 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 13:17:45 2014 +0200 gtktiledviewer: show part names in selector. Change-Id: I02ae5b729f96e36b3f226218b32495907cb63cf3 diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index 21cb179..d74eb96 100644 --- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx +++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <assert.h> #include <stdio.h> #include <string.h> @@ -122,10 +123,17 @@ void changeQuadView( GtkWidget* /*pButton*/, gpointer /* pItem */ ) #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 void populatePartSelector( GtkComboBoxText* pSelector, LOKDocView* pView ) { - char sText[10]; - for ( int i = 0; i < lok_docview_get_parts(pView); i++ ) + const int nMaxLength = 50; + char sText[nMaxLength]; + + int nParts = lok_docview_get_parts(pView); + for ( int i = 0; i < nParts; i++ ) { - sprintf( sText, "%i", i+1 ); + char* pName = lok_docview_get_part_name( pView, i ); + assert( pName ); + snprintf( sText, nMaxLength, "%i (%s)", i+1, pName ); + free( pName ); + gtk_combo_box_text_append_text( pSelector, sText ); } gtk_combo_box_set_active( GTK_COMBO_BOX(pSelector), 0 ); @@ -219,8 +227,10 @@ int main( int argc, char* argv[] ) gtk_widget_show_all( pWindow ); pFileName = argv[2]; - lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ); -// GtkComboBox requires gtk 2.24 or later + assert( lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] ) ); + assert( LOK_DOCVIEW(pDocView)->pDocument ); + + // GtkComboBox requires gtk 2.24 or later #if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2 populatePartSelector( GTK_COMBO_BOX_TEXT(pComboBox), LOK_DOCVIEW(pDocView) ); #endif commit 7c465793f6d970dd5c7a7fb0ac6bdfa9b2a32e58 Author: Andrzej Hunt <andrzej.h...@collabora.com> Date: Tue Jul 29 13:17:30 2014 +0200 LOKDocView: add part name retrieval. Change-Id: Iac31de0410d7f6187e5884152c329375047a23f4 diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index 37d21f0..a73f98d 100644 --- a/include/LibreOfficeKit/LibreOfficeKitGtk.h +++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h @@ -62,7 +62,8 @@ int lok_docview_get_parts (LOKDocView* pDocView); int lok_docview_get_part (LOKDocView* pDocView); void lok_docview_set_part (LOKDocView* pDocView, int nPart); - +char* lok_docview_get_part_name (LOKDocView* pDocView, + int nPart); #ifdef __cplusplus } #endif diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c index cdc2339..17c0a1c 100644 --- a/libreofficekit/source/gtk/lokdocview.c +++ b/libreofficekit/source/gtk/lokdocview.c @@ -190,5 +190,8 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart) renderDocument( pDocView ); } - +SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int nPart ) +{ + return pDocView->pDocument->pClass->getPartName( pDocView->pDocument, nPart ); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits