[Libreoffice-commits] core.git: extras/source sd/inc sd/qa sd/source sd/uiconfig solenv/bin
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 26 16:25:35 UTC 2020
extras/source/glade/libreoffice-catalog.xml.in | 3
sd/inc/helpids.h | 11
sd/inc/pch/precompiled_sd.hxx | 7
sd/inc/pch/precompiled_sdui.hxx | 12
sd/inc/strings.hrc | 6
sd/qa/unit/tiledrendering/tiledrendering.cxx | 21
sd/source/ui/dlg/navigatr.cxx | 411 +--
sd/source/ui/dlg/sdtreelb.cxx | 1312 ++--------
sd/source/ui/dlg/tpaction.cxx | 4
sd/source/ui/inc/DrawViewShell.hxx | 1
sd/source/ui/inc/navigatr.hxx | 25
sd/source/ui/inc/sdtreelb.hxx | 383 +-
sd/source/ui/slidesorter/controller/SlsClipboard.cxx | 10
sd/source/ui/slidesorter/controller/SlsDragAndDropContext.cxx | 4
sd/source/ui/view/drviews4.cxx | 13
sd/source/ui/view/sdview2.cxx | 6
sd/source/ui/view/tabcontr.cxx | 2
sd/uiconfig/simpress/ui/navigatorpanel.ui | 134 -
solenv/bin/native-code.py | 1
19 files changed, 810 insertions(+), 1556 deletions(-)
New commits:
commit 42f281c56e0c06327fa382c0984ecf2e8c21e414
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Feb 19 13:22:19 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Feb 26 17:24:59 2020 +0100
weld impress navigator
complicated by the effort to keep the non-standard behaviour of
commit f3c68cdf8f6a0273c62b493552f78af0138a44e8
Date: Wed Feb 21 17:27:53 2018 +0100
tdf#115873 sd navigator: allow selecting but not focusing on objects
and the self-dnd code
Change-Id: I29c224739463d1d44690f30ed29db3fe2b16b4a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89045
Tested-by: Caolán McNamara <caolanm at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 6edd3804e696..4d09187710dd 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -52,9 +52,6 @@
<glade-widget-class title="Animation ListBox" name="sdlo-CustomAnimationList"
generic-name="Animation ListBox" parent="GtkTreeView"
icon-name="widget-gtk-treeview"/>
- <glade-widget-class title="Page Objs ListBox" name="sdlo-SdPageObjsTLB"
- generic-name="SdPageObjsTLB" parent="GtkTreeView"
- icon-name="widget-gtk-treeview"/>
<glade-widget-class title="Page List Control" name="sduilo-SdPageListControl"
generic-name="Page List Control" parent="GtkTreeView"
icon-name="widget-gtk-treeview"/>
diff --git a/sd/inc/helpids.h b/sd/inc/helpids.h
index 0b2622f4c4c3..25b4625d06e6 100644
--- a/sd/inc/helpids.h
+++ b/sd/inc/helpids.h
@@ -24,13 +24,8 @@
#define HID_SDGRAPHICVIEWSHELL "SD_HID_SDGRAPHICVIEWSHELL"
#define HID_SDOUTLINEVIEWSHELL "SD_HID_SDOUTLINEVIEWSHELL"
-#define HID_SD_NAVIGATOR_MENU1 "SD_HID_SD_NAVIGATOR_MENU1"
-#define HID_SD_NAVIGATOR_MENU2 "SD_HID_SD_NAVIGATOR_MENU2"
-#define HID_SD_NAVIGATOR_MENU3 "SD_HID_SD_NAVIGATOR_MENU3"
-
#define HID_SD_WIN_PRESENTATION "SD_HID_SD_WIN_PRESENTATION"
-
#define HID_SD_HTMLEXPORT_PAGE1 "SD_HID_SD_HTMLEXPORT_PAGE1"
#define HID_SD_HTMLEXPORT_PAGE2 "SD_HID_SD_HTMLEXPORT_PAGE2"
#define HID_SD_HTMLEXPORT_PAGE3 "SD_HID_SD_HTMLEXPORT_PAGE3"
@@ -38,19 +33,13 @@
#define HID_SD_HTMLEXPORT_PAGE5 "SD_HID_SD_HTMLEXPORT_PAGE5"
#define HID_SD_HTMLEXPORT_PAGE6 "SD_HID_SD_HTMLEXPORT_PAGE6"
-
-
#define HID_SD_TABBAR_PAGES "SD_HID_SD_TABBAR_PAGES"
#define HID_SD_TABBAR_LAYERS "SD_HID_SD_TABBAR_LAYERS"
-
#define HID_SD_NAMEDIALOG_OBJECT "SD_HID_SD_NAMEDIALOG_OBJECT"
#define HID_SD_NAMEDIALOG_PAGE "SD_HID_SD_NAMEDIALOG_PAGE"
#define HID_SD_NAMEDIALOG_LINEEND "SD_HID_SD_NAMEDIALOG_LINEEND"
-
-
-
#define HID_SD_TASK_PANE_PREVIEW_CURRENT "SD_HID_SD_TASK_PANE_PREVIEW_CURRENT"
#define HID_SD_TASK_PANE_PREVIEW_RECENT "SD_HID_SD_TASK_PANE_PREVIEW_RECENT"
#define HID_SD_TASK_PANE_PREVIEW_ALL "SD_HID_SD_TASK_PANE_PREVIEW_ALL"
diff --git a/sd/inc/pch/precompiled_sd.hxx b/sd/inc/pch/precompiled_sd.hxx
index d352ebae06e3..739759515976 100644
--- a/sd/inc/pch/precompiled_sd.hxx
+++ b/sd/inc/pch/precompiled_sd.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-02-13 21:37:42 using:
+ Generated on 2020-02-25 20:28:15 using:
./bin/update_pch sd sd --cutoff=4 --exclude:system --exclude:module --include:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -32,6 +32,7 @@
#include <map>
#include <memory>
#include <new>
+#include <optional>
#include <ostream>
#include <set>
#include <stddef.h>
@@ -72,7 +73,7 @@
#include <sal/typesizes.h>
#include <vcl/EnumContext.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/builderfactory.hxx>
+#include <vcl/builder.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/ctrl.hxx>
@@ -166,6 +167,7 @@
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/framework/ResourceId.hpp>
#include <com/sun/star/drawing/framework/XConfiguration.hpp>
#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
@@ -294,7 +296,6 @@
#include <model/SlsPageEnumerationProvider.hxx>
#include <o3tl/cow_wrapper.hxx>
#include <o3tl/deleter.hxx>
-#include <optional>
#include <o3tl/safeint.hxx>
#include <o3tl/strong_int.hxx>
#include <o3tl/typed_flags_set.hxx>
diff --git a/sd/inc/pch/precompiled_sdui.hxx b/sd/inc/pch/precompiled_sdui.hxx
index d8fec6e26373..0dad26f2c9dc 100644
--- a/sd/inc/pch/precompiled_sdui.hxx
+++ b/sd/inc/pch/precompiled_sdui.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-02-01 11:00:25 using:
+ Generated on 2020-02-25 20:28:19 using:
./bin/update_pch sd sdui --cutoff=4 --exclude:system --include:module --include:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -39,6 +39,7 @@
#include <math.h>
#include <memory>
#include <new>
+#include <optional>
#include <ostream>
#include <set>
#include <sstream>
@@ -100,7 +101,6 @@
#include <vcl/ITiledRenderable.hxx>
#include <vcl/NotebookBarAddonsMerger.hxx>
#include <vcl/Scanline.hxx>
-#include <vcl/accel.hxx>
#include <vcl/alpha.hxx>
#include <vcl/animate/Animation.hxx>
#include <vcl/animate/AnimationBitmap.hxx>
@@ -133,12 +133,10 @@
#include <vcl/menu.hxx>
#include <vcl/metaactiontypes.hxx>
#include <vcl/metric.hxx>
-#include <vcl/mnemonicengine.hxx>
#include <vcl/outdev.hxx>
#include <vcl/outdevmap.hxx>
#include <vcl/outdevstate.hxx>
#include <vcl/ptrstyle.hxx>
-#include <vcl/quickselectionengine.hxx>
#include <vcl/region.hxx>
#include <vcl/salgtype.hxx>
#include <vcl/salnativewidgets.hxx>
@@ -150,8 +148,6 @@
#include <vcl/textfilter.hxx>
#include <vcl/timer.hxx>
#include <vcl/transfer.hxx>
-#include <vcl/treelist.hxx>
-#include <vcl/treelistentries.hxx>
#include <vcl/uitest/factory.hxx>
#include <vcl/vclenum.hxx>
#include <vcl/vclevent.hxx>
@@ -327,14 +323,11 @@
#include <editeng/paragraphdata.hxx>
#include <editeng/svxenum.hxx>
#include <editeng/svxfont.hxx>
-#include <helper/simplereferencecomponent.hxx>
#include <i18nlangtag/i18nlangtagdllapi.h>
#include <i18nlangtag/lang.h>
-#include <i18nlangtag/languagetag.hxx>
#include <o3tl/cow_wrapper.hxx>
#include <o3tl/deleter.hxx>
#include <o3tl/enumarray.hxx>
-#include <optional>
#include <o3tl/safeint.hxx>
#include <o3tl/sorted_vector.hxx>
#include <o3tl/strong_int.hxx>
@@ -429,7 +422,6 @@
#include <svx/xpoly.hxx>
#include <svx/xtable.hxx>
#include <tools/color.hxx>
-#include <tools/contnr.hxx>
#include <tools/date.hxx>
#include <tools/datetime.hxx>
#include <tools/debug.hxx>
diff --git a/sd/inc/strings.hrc b/sd/inc/strings.hrc
index 400b8ec22b00..08481d170398 100644
--- a/sd/inc/strings.hrc
+++ b/sd/inc/strings.hrc
@@ -157,9 +157,6 @@
// Strings for animation effects
#define STR_INSERT_TEXT NC_("STR_INSERT_TEXT", "Insert Text")
#define STR_LOAD_PRESENTATION_LAYOUT NC_("STR_LOAD_PRESENTATION_LAYOUT", "Load Master Slide")
-#define STR_DRAGTYPE_URL NC_("STR_DRAGTYPE_URL", "Insert as Hyperlink")
-#define STR_DRAGTYPE_EMBEDDED NC_("STR_DRAGTYPE_EMBEDDED", "Insert as Copy")
-#define STR_DRAGTYPE_LINK NC_("STR_DRAGTYPE_LINK", "Insert as Link")
#define STR_GLUE_ESCDIR_SMART NC_("STR_GLUE_ESCDIR_SMART", "Smart")
#define STR_GLUE_ESCDIR_LEFT NC_("STR_GLUE_ESCDIR_LEFT", "Left")
#define STR_GLUE_ESCDIR_RIGHT NC_("STR_GLUE_ESCDIR_RIGHT", "Right")
@@ -263,8 +260,6 @@
#define STR_GRAPHICS_STYLE_FAMILY NC_("STR_GRAPHICS_STYLE_FAMILY", "Drawing Styles")
#define STR_PRESENTATIONS_STYLE_FAMILY NC_("STR_PRESENTATIONS_STYLE_FAMILY", "Presentation Styles")
#define STR_CELL_STYLE_FAMILY NC_("STR_CELL_STYLE_FAMILY", "Cell Styles")
-#define STR_NAVIGATOR_SHOW_NAMED_SHAPES NC_("STR_NAVIGATOR_SHOW_NAMED_SHAPES", "Named shapes")
-#define STR_NAVIGATOR_SHOW_ALL_SHAPES NC_("STR_NAVIGATOR_SHOW_ALL_SHAPES", "All shapes")
#define STR_NAVIGATOR_SHAPE_BASE_NAME NC_("STR_NAVIGATOR_SHAPE_BASE_NAME", "Shape %1")
#define STR_SET_BACKGROUND_PICTURE NC_("STR_SET_BACKGROUND_PICTURE", "Set Background Image" )
#define RID_ANNOTATIONS_START NC_("RID_ANNOTATIONS_START", "Comments")
@@ -277,7 +272,6 @@
#define STRING_DRAG_AND_DROP_SLIDES NC_("STRING_DRAG_AND_DROP_SLIDES", "Drag and Drop Slides" )
#define STR_PHOTO_ALBUM_EMPTY_WARNING NC_("STR_PHOTO_ALBUM_EMPTY_WARNING", "Please add Images to the Album." )
#define STR_PHOTO_ALBUM_TEXTBOX NC_("STR_PHOTO_ALBUM_TEXTBOX", "Text Slide")
-#define STR_OBJECTS_TREE NC_("STR_OBJECTS_TREE", "Page Tree")
#define STR_OVERWRITE_WARNING NC_("STR_OVERWRITE_WARNING", "The local target directory '%FILENAME' is not empty. Some files might be overwritten. Do you want to continue?")
#define STR_LAYER_BCKGRND NC_("STR_LAYER_BCKGRND", "Background" )
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 2fe192f66de9..3f374b0fa051 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2114,8 +2114,9 @@ void SdTiledRenderingTest::testTdf115873()
ScopedVclPtrInstance<SdNavigatorWin> pNavigator(nullptr, &rBindings);
pNavigator->InitTreeLB(pXImpressDocument->GetDoc());
pNavigator->Show();
- VclPtr<SdPageObjsTLB> pObjects = pNavigator->GetObjects();
- pObjects->Select(pObjects->GetEntry(0));
+ SdPageObjsTLV& rObjects = pNavigator->GetObjects();
+ rObjects.SelectEntry("Slide 1");
+ rObjects.Select();
sd::ViewShell* pSdViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
SdrView* pSdrView = pSdViewShell->GetView();
pSdrView->UnmarkAllObj(pSdrView->GetSdrPageView());
@@ -2126,13 +2127,11 @@ void SdTiledRenderingTest::testTdf115873()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rMarkList.GetMarkCount());
// Single-click with the mouse.
- short nHeight = pObjects->GetEntryHeight();
- // Position of the center of the 2nd entry (first is the slide, second is
- // the shape).
- Point aPoint(pObjects->GetOutputWidthPixel() / 2, nHeight * 1.5);
- MouseEvent aMouseEvent(aPoint, /*nClicks=*/1, MouseEventModifiers::NONE, MOUSE_LEFT);
- pObjects->MouseButtonDown(aMouseEvent);
- pObjects->MouseButtonUp(aMouseEvent);
+ MouseEvent aMouseEvent(Point(0, 0), /*nClicks=*/1, MouseEventModifiers::NONE, MOUSE_LEFT);
+ rObjects.MousePressHdl(aMouseEvent);
+ rObjects.SelectEntry("Rectangle");
+ rObjects.Select();
+ rObjects.MouseReleaseHdl(aMouseEvent);
Scheduler::ProcessEventsToIdle();
// This failed, single-click did not result in a shape selection (only
// double-click did).
@@ -2148,10 +2147,10 @@ void SdTiledRenderingTest::testTdf115873Group()
SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
ScopedVclPtrInstance<SdNavigatorWin> pNavigator(nullptr, &rBindings);
pNavigator->InitTreeLB(pXImpressDocument->GetDoc());
- VclPtr<SdPageObjsTLB> pObjects = pNavigator->GetObjects();
+ SdPageObjsTLV& rObjects = pNavigator->GetObjects();
// This failed, Fill() and IsEqualToDoc() were out of sync for group
// shapes.
- CPPUNIT_ASSERT(pObjects->IsEqualToDoc(pXImpressDocument->GetDoc()));
+ CPPUNIT_ASSERT(rObjects.IsEqualToDoc(pXImpressDocument->GetDoc()));
}
void SdTiledRenderingTest::testCutSelectionChange()
diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx
index b5b0d608b4da..18fe916f0050 100644
--- a/sd/source/ui/dlg/navigatr.cxx
+++ b/sd/source/ui/dlg/navigatr.cxx
@@ -49,52 +49,46 @@
#include <helpids.h>
#include <Window.hxx>
-namespace {
-static const sal_uInt16 nShowNamedShapesFilter=1;
-static const sal_uInt16 nShowAllShapesFilter=2;
-}
-
/**
* SdNavigatorWin - FloatingWindow
*/
SdNavigatorWin::SdNavigatorWin(vcl::Window* pParent, SfxBindings* pInBindings)
- : PanelLayout(pParent, "NavigatorPanel", "modules/simpress/ui/navigatorpanel.ui", nullptr)
+ : PanelLayout(pParent, "NavigatorPanel", "modules/simpress/ui/navigatorpanel.ui", nullptr, true)
+ , mxToolbox(m_xBuilder->weld_toolbar("toolbox"))
+ , mxTlbObjects(new SdPageObjsTLV(m_xBuilder->weld_tree_view("tree")))
+ , mxLbDocs(m_xBuilder->weld_combo_box("documents"))
+ , mxDragModeMenu(m_xBuilder->weld_menu("dragmodemenu"))
+ , mxShapeMenu(m_xBuilder->weld_menu("shapemenu"))
, mbDocImported ( false )
// On changes of the DragType: adjust SelectionMode of TLB!
, meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED )
, mpBindings ( pInBindings )
{
- get(maToolbox, "toolbox");
- get(maTlbObjects, "tree");
- Size aSize(maTlbObjects->LogicToPixel(Size(97, 67), MapMode(MapUnit::MapAppFont)));
- maTlbObjects->set_height_request(aSize.Width());
- maTlbObjects->set_width_request(aSize.Height());
- get(maLbDocs, "documents");
+ Size aSize(LogicToPixel(Size(97, 67), MapMode(MapUnit::MapAppFont)));
+ mxTlbObjects->set_size_request(aSize.Width(), aSize.Height());
+ mxTlbObjects->SetViewFrame( mpBindings->GetDispatcher()->GetFrame() );
- maTlbObjects->SetViewFrame( mpBindings->GetDispatcher()->GetFrame() );
+ mxTlbObjects->connect_row_activated(LINK(this, SdNavigatorWin, ClickObjectHdl));
+ mxTlbObjects->set_selection_mode(SelectionMode::Single);
- maTlbObjects->SetAccessibleName(SdResId(STR_OBJECTS_TREE));
+ mxToolbox->connect_clicked(LINK(this, SdNavigatorWin, SelectToolboxHdl));
+ mxToolbox->connect_menu_toggled(LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl));
- maTlbObjects->SetDoubleClickHdl(LINK(this, SdNavigatorWin, ClickObjectHdl));
- maTlbObjects->SetSelectionMode(SelectionMode::Single);
-
- maToolbox->SetSelectHdl( LINK( this, SdNavigatorWin, SelectToolboxHdl ) );
- maToolbox->SetDropdownClickHdl( LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl) );
- const sal_uInt16 nDragTypeId = maToolbox->GetItemId("dragmode");
- maToolbox->SetItemBits(nDragTypeId, maToolbox->GetItemBits(nDragTypeId) | ToolBoxItemBits::DROPDOWNONLY);
+ mxToolbox->set_item_menu("dragmode", mxDragModeMenu.get());
+ mxDragModeMenu->connect_activate(LINK(this, SdNavigatorWin, MenuSelectHdl));
// Shape filter drop down menu.
- const sal_uInt16 nShapeId = maToolbox->GetItemId("shapes");
- maToolbox->SetItemBits(nShapeId, maToolbox->GetItemBits(nShapeId) | ToolBoxItemBits::DROPDOWNONLY);
+ mxToolbox->set_item_menu("shapes", mxShapeMenu.get());
+ mxShapeMenu->connect_activate(LINK(this, SdNavigatorWin, ShapeFilterCallback));
// set focus to listbox, otherwise it is in the toolbox which is only useful
// for keyboard navigation
- maTlbObjects->GrabFocus();
- maTlbObjects->SetSdNavigator(this);
+ mxTlbObjects->grab_focus();
+ mxTlbObjects->SetSdNavigator(this);
// DragTypeListBox
- maLbDocs->setMaxWidthChars(20);
- maLbDocs->SetSelectHdl( LINK( this, SdNavigatorWin, SelectDocumentHdl ) );
+ mxLbDocs->set_size_request(42, -1); // set a nominal width so it takes width of surroundings
+ mxLbDocs->connect_changed(LINK(this, SdNavigatorWin, SelectDocumentHdl));
SetDragImage();
}
@@ -118,9 +112,11 @@ void SdNavigatorWin::dispose()
{
mpNavigatorCtrlItem.reset();
mpPageNameCtrlItem.reset();
- maToolbox.clear();
- maTlbObjects.clear();
- maLbDocs.clear();
+ mxDragModeMenu.reset();
+ mxShapeMenu.reset();
+ mxToolbox.reset();
+ mxTlbObjects.reset();
+ mxLbDocs.reset();
PanelLayout::dispose();
}
@@ -131,17 +127,9 @@ void SdNavigatorWin::FreshTree( const SdDrawDocument* pDoc )
sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh();
const OUString& aDocShName( pDocShell->GetName() );
OUString aDocName = pDocShell->GetMedium()->GetName();
- maTlbObjects->SetSaveTreeItemStateFlag(true); //Added by yanjun for sym2_6385
- maTlbObjects->Clear();
- maTlbObjects->Fill( pDoc, false, aDocName ); // Only normal pages
- maTlbObjects->SetSaveTreeItemStateFlag(false); //Added by yanjun for sym2_6385
+ mxTlbObjects->Fill( pDoc, false, aDocName ); // Only normal pages
RefreshDocumentLB();
- maLbDocs->SelectEntry( aDocShName );
-}
-
-void SdNavigatorWin::FreshEntry( )
-{
- maTlbObjects->Invalidate();
+ mxLbDocs->set_active_text(aDocShName);
}
void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc )
@@ -157,36 +145,35 @@ void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc )
{
::sd::FrameView* pFrameView = pViewShell->GetFrameView();
if (pFrameView != nullptr)
- maTlbObjects->SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
+ mxTlbObjects->SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false);
}
// Disable the shape filter drop down menu when there is a running slide
// show.
- const sal_uInt16 nShapeId = maToolbox->GetItemId("shapes");
if (pViewShell!=nullptr && sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() ))
- maToolbox->EnableItem(nShapeId, false);
+ mxToolbox->set_item_sensitive("shapes", false);
else
- maToolbox->EnableItem(nShapeId);
+ mxToolbox->set_item_sensitive("shapes", true);
- if( !maTlbObjects->IsEqualToDoc( pDoc ) )
+ if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
{
OUString aDocName = pDocShell->GetMedium()->GetName();
- maTlbObjects->Clear();
- maTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
+ mxTlbObjects->clear();
+ mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
RefreshDocumentLB();
- maLbDocs->SelectEntry( aDocShName );
+ mxLbDocs->set_active_text(aDocShName);
}
else
{
- maLbDocs->SetNoSelection();
- maLbDocs->SelectEntry( aDocShName );
+ mxLbDocs->set_active(-1);
+ mxLbDocs->set_active_text(aDocShName);
// commented in order to fix 30246
-// if( maLbDocs->GetSelectedEntryCount() == 0 )
+// if( mxLbDocs->get_active() == -1 )
{
RefreshDocumentLB();
- maLbDocs->SelectEntry( aDocShName );
+ mxLbDocs->set_active_text(aDocShName);
}
}
@@ -204,45 +191,33 @@ NavigatorDragType SdNavigatorWin::GetNavigatorDragType()
NavigatorDragType eDT = meDragType;
NavDocInfo* pInfo = GetDocInfo();
- if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !maTlbObjects->IsLinkableSelected() ) )
+ if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() ) )
eDT = NAVIGATOR_DRAGTYPE_NONE;
return eDT;
}
-VclPtr<SdPageObjsTLB> const & SdNavigatorWin::GetObjects() const
+SdPageObjsTLV& SdNavigatorWin::GetObjects()
{
- return maTlbObjects;
+ return *mxTlbObjects;
}
-IMPL_LINK_NOARG(SdNavigatorWin, SelectToolboxHdl, ToolBox *, void)
+IMPL_LINK(SdNavigatorWin, SelectToolboxHdl, const OString&, rCommand, void)
{
- sal_uInt16 nId = maToolbox->GetCurItemId();
- const OUString sCommand = maToolbox->GetItemCommand(nId);
PageJump ePage = PAGE_NONE;
- if (sCommand == "first")
- {
+ if (rCommand == "first")
ePage = PAGE_FIRST;
- maTlbObjects->Select( maTlbObjects->GetFirstEntryInView() );
- }
- else if (sCommand == "previous")
- {
+ else if (rCommand == "previous")
ePage = PAGE_PREVIOUS;
- if( maTlbObjects->GetPrevEntryInView( maTlbObjects->GetCurEntry() ) != nullptr )
- maTlbObjects->Select( maTlbObjects->GetPrevEntryInView( maTlbObjects->GetCurEntry() ) );
- }
- else if (sCommand == "next")
- {
+ else if (rCommand == "next")
ePage = PAGE_NEXT;
- if( maTlbObjects->GetNextEntryInView( maTlbObjects->GetCurEntry() ) != nullptr )
- maTlbObjects->Select( maTlbObjects->GetNextEntryInView( maTlbObjects->GetCurEntry() ) );
- }
- else if (sCommand == "last")
- {
+ else if (rCommand == "last")
ePage = PAGE_LAST;
- maTlbObjects->Select( maTlbObjects->GetLastEntryInView() );
- }
+ else if (rCommand == "dragmode")
+ mxToolbox->set_menu_item_active("dragmode", !mxToolbox->get_menu_item_active("dragmode"));
+ else if (rCommand == "shapes")
+ mxToolbox->set_menu_item_active("shapes", !mxToolbox->get_menu_item_active("shapes"));
if (ePage != PAGE_NONE)
{
@@ -252,84 +227,41 @@ IMPL_LINK_NOARG(SdNavigatorWin, SelectToolboxHdl, ToolBox *, void)
}
}
-IMPL_LINK( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox, void )
+IMPL_LINK(SdNavigatorWin, DropdownClickToolBoxHdl, const OString&, rCommand, void)
{
- sal_uInt16 nId = maToolbox->GetCurItemId();
- const OUString sCommand = maToolbox->GetItemCommand(nId);
+ if (!mxToolbox->get_menu_item_active(rCommand))
+ return;
- if (sCommand == "dragmode")
+ if (rCommand == "dragmode")
{
- // Popup menu is created depending if the document is saved or not
- ScopedVclPtrInstance<PopupMenu> pMenu;
-
- static const char* aHIDs[] =
- {
- HID_SD_NAVIGATOR_MENU1,
- HID_SD_NAVIGATOR_MENU2,
- HID_SD_NAVIGATOR_MENU3,
- nullptr
- };
-
- for (sal_uInt16 nID = NAVIGATOR_DRAGTYPE_URL; nID < NAVIGATOR_DRAGTYPE_COUNT; ++nID)
- {
- const char* pRId = GetDragTypeSdStrId(static_cast<NavigatorDragType>(nID));
- if (pRId)
- {
- DBG_ASSERT(aHIDs[nID-NAVIGATOR_DRAGTYPE_URL],"HelpId not added!");
- pMenu->InsertItem(nID, SdResId(pRId), MenuItemBits::RADIOCHECK);
- pMenu->SetHelpId(nID, aHIDs[nID - NAVIGATOR_DRAGTYPE_URL]);
- }
-
- }
NavDocInfo* pInfo = GetDocInfo();
-
- if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects->IsLinkableSelected() )
+ if( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() )
{
- pMenu->EnableItem( NAVIGATOR_DRAGTYPE_LINK, false );
- pMenu->EnableItem( NAVIGATOR_DRAGTYPE_URL, false );
+ mxDragModeMenu->set_sensitive(OString::number(NAVIGATOR_DRAGTYPE_LINK), false);
+ mxDragModeMenu->set_sensitive(OString::number(NAVIGATOR_DRAGTYPE_URL), false);
meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
}
- pMenu->CheckItem( static_cast<sal_uInt16>(meDragType) );
- pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, MenuSelectHdl ) );
-
- pMenu->Execute( this, maToolbox->GetItemRect( nId ), PopupMenuFlags::ExecuteDown );
- pBox->EndSelection();
+ mxDragModeMenu->set_active(OString::number(meDragType), true);
}
- else if (sCommand == "shapes")
+ else if (rCommand == "shapes")
{
- ScopedVclPtrInstance<PopupMenu> pMenu;
-
- pMenu->InsertItem(
- nShowNamedShapesFilter,
- SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES),
- MenuItemBits::RADIOCHECK);
- pMenu->InsertItem(
- nShowAllShapesFilter,
- SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES),
- MenuItemBits::RADIOCHECK);
-
- if (maTlbObjects->GetShowAllShapes())
- pMenu->CheckItem(nShowAllShapesFilter);
- else
- pMenu->CheckItem(nShowNamedShapesFilter);
- pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, ShapeFilterCallback ) );
-
- pMenu->Execute( this, maToolbox->GetItemRect( nId ), PopupMenuFlags::ExecuteDown );
- pBox->EndSelection();
+ bool bAll = mxTlbObjects->GetShowAllShapes();
+ mxShapeMenu->set_active("named", !bAll);
+ mxShapeMenu->set_active("all", bAll);
}
}
-IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, weld::TreeView&, bool)
{
- if( !mbDocImported || maLbDocs->GetSelectedEntryPos() != 0 )
+ if( !mbDocImported || mxLbDocs->get_active() != 0 )
{
NavDocInfo* pInfo = GetDocInfo();
// if it is the active window, we jump to the page
if( pInfo && pInfo->IsActive() )
{
- OUString aStr( maTlbObjects->GetSelectedEntry() );
+ OUString aStr(mxTlbObjects->get_selected_text());
if( !aStr.isEmpty() )
{
@@ -337,8 +269,6 @@ IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, SvTreeListBox*, bool)
mpBindings->GetDispatcher()->ExecuteList(
SID_NAVIGATOR_OBJECT,
SfxCallMode::SLOT | SfxCallMode::RECORD, { &aItem });
- //set sign variable
- maTlbObjects->Invalidate();
// moved here from SetGetFocusHdl. Reset the
// focus only if something has been selected in the
@@ -368,20 +298,20 @@ IMPL_LINK_NOARG(SdNavigatorWin, ClickObjectHdl, SvTreeListBox*, bool)
}
}
- if (!maTlbObjects->IsNavigationGrabsFocus())
+ if (!mxTlbObjects->IsNavigationGrabsFocus())
// This is the case when keyboard navigation inside the
// navigator should continue to work.
- maTlbObjects->GrabFocus();
+ mxTlbObjects->grab_focus();
}
}
}
return false;
}
-IMPL_LINK_NOARG(SdNavigatorWin, SelectDocumentHdl, ListBox&, void)
+IMPL_LINK_NOARG(SdNavigatorWin, SelectDocumentHdl, weld::ComboBox&, void)
{
- OUString aStrLb = maLbDocs->GetSelectedEntry();
- long nPos = maLbDocs->GetSelectedEntryPos();
+ OUString aStrLb = mxLbDocs->get_active_text();
+ long nPos = mxLbDocs->get_active();
bool bFound = false;
::sd::DrawDocShell* pDocShell = nullptr;
NavDocInfo* pInfo = GetDocInfo();
@@ -402,18 +332,18 @@ IMPL_LINK_NOARG(SdNavigatorWin, SelectDocumentHdl, ListBox&, void)
if( bFound )
{
SdDrawDocument* pDoc = pDocShell->GetDoc();
- if( !maTlbObjects->IsEqualToDoc( pDoc ) )
+ if( !mxTlbObjects->IsEqualToDoc( pDoc ) )
{
SdDrawDocument* pNonConstDoc = pDoc; // const as const can...
::sd::DrawDocShell* pNCDocShell = pNonConstDoc->GetDocSh();
OUString aDocName = pNCDocShell->GetMedium()->GetName();
- maTlbObjects->Clear();
- maTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
+ mxTlbObjects->clear();
+ mxTlbObjects->Fill( pDoc, false, aDocName ); // only normal pages
}
}
// check if link or url is possible
- if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects->IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
+ if( ( pInfo && !pInfo->HasName() ) || !mxTlbObjects->IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) )
{
meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED;
SetDragImage();
@@ -422,84 +352,60 @@ IMPL_LINK_NOARG(SdNavigatorWin, SelectDocumentHdl, ListBox&, void)
/**
* Set DrageType and set image accordingly to it.
- * If the handler is called with NULL, the default (URL) is set.
*/
-IMPL_LINK( SdNavigatorWin, MenuSelectHdl, Menu *, pMenu, bool )
+IMPL_LINK(SdNavigatorWin, MenuSelectHdl, const OString&, rIdent, void)
{
- sal_uInt16 nMenuId;
- if( pMenu )
- nMenuId = pMenu->GetCurItemId();
- else
- nMenuId = NAVIGATOR_DRAGTYPE_URL;
+ sal_uInt32 nMenuId = rIdent.toUInt32();
- if( nMenuId != USHRT_MAX ) // Necessary ?
+ NavigatorDragType eDT = static_cast<NavigatorDragType>(nMenuId);
+ if( meDragType != eDT )
{
- NavigatorDragType eDT = static_cast<NavigatorDragType>(nMenuId);
- if( meDragType != eDT )
- {
- meDragType = eDT;
- SetDragImage();
+ meDragType = eDT;
+ SetDragImage();
- if( meDragType == NAVIGATOR_DRAGTYPE_URL )
- {
- // patch, prevents endless loop
- if( maTlbObjects->GetSelectionCount() > 1 )
- maTlbObjects->SelectAll( false );
+ if( meDragType == NAVIGATOR_DRAGTYPE_URL )
+ {
+ // patch, prevents endless loop
+ if (mxTlbObjects->count_selected_rows() > 1)
+ mxTlbObjects->unselect_all();
- maTlbObjects->SetSelectionMode( SelectionMode::Single );
- }
- else
- maTlbObjects->SetSelectionMode( SelectionMode::Multiple );
+ mxTlbObjects->set_selection_mode(SelectionMode::Single);
}
+ else
+ mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
}
- return false;
}
-IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, Menu *, pMenu, bool )
+IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, const OString&, rIdent, void )
{
- if (pMenu != nullptr)
- {
- bool bShowAllShapes (maTlbObjects->GetShowAllShapes());
- sal_uInt16 nMenuId (pMenu->GetCurItemId());
- switch (nMenuId)
- {
- case nShowNamedShapesFilter:
- bShowAllShapes = false;
- break;
-
- case nShowAllShapesFilter:
- bShowAllShapes = true;
- break;
-
- default:
- OSL_FAIL(
- "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
- break;
- }
+ bool bShowAllShapes(mxTlbObjects->GetShowAllShapes());
+ if (rIdent == "named")
+ bShowAllShapes = false;
+ else if (rIdent == "all")
+ bShowAllShapes = true;
+ else
+ OSL_FAIL("SdNavigatorWin::ShapeFilterCallback called for unknown menu entry");
- maTlbObjects->SetShowAllShapes(bShowAllShapes, true);
+ mxTlbObjects->SetShowAllShapes(bShowAllShapes, true);
- // Remember the selection in the FrameView.
- NavDocInfo* pInfo = GetDocInfo();
- if (pInfo != nullptr)
+ // Remember the selection in the FrameView.
+ NavDocInfo* pInfo = GetDocInfo();
+ if (pInfo != nullptr)
+ {
+ ::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
+ if (pDocShell != nullptr)
{
- ::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
- if (pDocShell != nullptr)
+ ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
+ if (pViewShell != nullptr)
{
- ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
- if (pViewShell != nullptr)
+ ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
+ if (pFrameView != nullptr)
{
- ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
- if (pFrameView != nullptr)
- {
- pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
- }
+ pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
}
}
}
}
-
- return false;
}
bool SdNavigatorWin::InsertFile(const OUString& rFileName)
@@ -545,19 +451,19 @@ bool SdNavigatorWin::InsertFile(const OUString& rFileName)
if (xMedium->IsStorage())
{
// Now depending on mode:
- // maTlbObjects->SetSelectionMode(SelectionMode::Multiple);
+ // mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
// handover of ownership of xMedium;
- SdDrawDocument* pDropDoc = maTlbObjects->GetBookmarkDoc(xMedium.release());
+ SdDrawDocument* pDropDoc = mxTlbObjects->GetBookmarkDoc(xMedium.release());
if (pDropDoc)
{
- maTlbObjects->Clear();
+ mxTlbObjects->clear();
maDropFileName = aFileName;
- if( !maTlbObjects->IsEqualToDoc( pDropDoc ) )
+ if( !mxTlbObjects->IsEqualToDoc( pDropDoc ) )
{
// only normal pages
- maTlbObjects->Fill(pDropDoc, false, maDropFileName);
+ mxTlbObjects->Fill(pDropDoc, false, maDropFileName);
RefreshDocumentLB( &maDropFileName );
}
}
@@ -583,28 +489,28 @@ void SdNavigatorWin::RefreshDocumentLB( const OUString* pDocName )
if( pDocName )
{
if( mbDocImported )
- maLbDocs->RemoveEntry( 0 );
+ mxLbDocs->remove(0);
- maLbDocs->InsertEntry( *pDocName, 0 );
+ mxLbDocs->insert_text(0, *pDocName);
mbDocImported = true;
}
else
{
- nPos = maLbDocs->GetSelectedEntryPos();
- if( nPos == LISTBOX_ENTRY_NOTFOUND )
+ nPos = mxLbDocs->get_active();
+ if (nPos == -1)
nPos = 0;
OUString aStr;
if( mbDocImported )
- aStr = maLbDocs->GetEntry( 0 );
+ aStr = mxLbDocs->get_text(0);
- maLbDocs->Clear();
+ mxLbDocs->clear();
// delete list of DocInfos
maDocList.clear();
if( mbDocImported )
- maLbDocs->InsertEntry( aStr, 0 );
+ mxLbDocs->insert_text(0, aStr);
::sd::DrawDocShell* pCurrentDocShell =
dynamic_cast< ::sd::DrawDocShell *>( SfxObjectShell::Current() );
@@ -628,7 +534,7 @@ void SdNavigatorWin::RefreshDocumentLB( const OUString* pDocName )
// is shown in url notation!
aStr = pDocShell->GetName();
- maLbDocs->InsertEntry( aStr );
+ mxLbDocs->append_text(aStr);
if( pDocShell == pCurrentDocShell )
aInfo.SetActive( true );
@@ -640,24 +546,7 @@ void SdNavigatorWin::RefreshDocumentLB( const OUString* pDocName )
pSfxDocShell = SfxObjectShell::GetNext( *pSfxDocShell, [](const SfxObjectShell*){return true;}, false );
}
}
- maLbDocs->SelectEntryPos( nPos );
-}
-
-const char* SdNavigatorWin::GetDragTypeSdStrId(NavigatorDragType eDT)
-{
- switch( eDT )
- {
- case NAVIGATOR_DRAGTYPE_NONE:
- return STR_SD_NONE;
- case NAVIGATOR_DRAGTYPE_URL:
- return STR_DRAGTYPE_URL;
- case NAVIGATOR_DRAGTYPE_EMBEDDED:
- return STR_DRAGTYPE_EMBEDDED;
- case NAVIGATOR_DRAGTYPE_LINK:
- return STR_DRAGTYPE_LINK;
- default: OSL_FAIL( "No resource for DragType available!" );
- }
- return nullptr;
+ mxLbDocs->set_active(nPos);
}
OUString SdNavigatorWin::GetDragTypeSdBmpId(NavigatorDragType eDT)
@@ -679,7 +568,7 @@ OUString SdNavigatorWin::GetDragTypeSdBmpId(NavigatorDragType eDT)
NavDocInfo* SdNavigatorWin::GetDocInfo()
{
- sal_uInt32 nPos = maLbDocs->GetSelectedEntryPos();
+ sal_uInt32 nPos = mxLbDocs->get_active();
if( mbDocImported )
{
@@ -705,7 +594,7 @@ bool SdNavigatorWin::EventNotify(NotifyEvent& rNEvt)
{
if( KEY_ESCAPE == pKEvt->GetKeyCode().GetCode() )
{
- if( SdPageObjsTLB::IsInDrag() )
+ if( SdPageObjsTLV::IsInDrag() )
{
// during drag'n'drop we just stop the drag but do not close the navigator
bOK = true;
@@ -741,7 +630,7 @@ void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt )
if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
{
- if( SdPageObjsTLB::IsInDrag() )
+ if( SdPageObjsTLV::IsInDrag() )
{
// during drag'n'drop we just stop the drag but do not close the navigator
bOK = true;
@@ -764,8 +653,7 @@ void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt )
void SdNavigatorWin::SetDragImage()
{
- const sal_uInt16 nDragTypeId = maToolbox->GetItemId("dragmode");
- maToolbox->SetItemImage(nDragTypeId, Image(StockImage::Yes, GetDragTypeSdBmpId(meDragType)));
+ mxToolbox->set_item_icon_name("dragmode", GetDragTypeSdBmpId(meDragType));
}
/**
@@ -796,42 +684,37 @@ void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId,
if( !(pInfo && pInfo->IsActive()) )
return;
- sal_uInt16 nFirstId = pNavigatorWin->maToolbox->GetItemId("first");
- sal_uInt16 nPrevId = pNavigatorWin->maToolbox->GetItemId("previous");
- sal_uInt16 nLastId = pNavigatorWin->maToolbox->GetItemId("last");
- sal_uInt16 nNextId = pNavigatorWin->maToolbox->GetItemId("next");
-
// First
if (nState & NavState::BtnFirstEnabled &&
- !pNavigatorWin->maToolbox->IsItemEnabled(nFirstId))
- pNavigatorWin->maToolbox->EnableItem(nFirstId);
+ !pNavigatorWin->mxToolbox->get_item_sensitive("first"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("first", true);
if (nState & NavState::BtnFirstDisabled &&
- pNavigatorWin->maToolbox->IsItemEnabled(nFirstId))
- pNavigatorWin->maToolbox->EnableItem(nFirstId, false);
+ pNavigatorWin->mxToolbox->get_item_sensitive("first"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("first", false);
// Prev
if (nState & NavState::BtnPrevEnabled &&
- !pNavigatorWin->maToolbox->IsItemEnabled(nPrevId))
- pNavigatorWin->maToolbox->EnableItem(nPrevId);
+ !pNavigatorWin->mxToolbox->get_item_sensitive("previous"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("previous", true);
if (nState & NavState::BtnPrevDisabled &&
- pNavigatorWin->maToolbox->IsItemEnabled(nPrevId))
- pNavigatorWin->maToolbox->EnableItem(nPrevId, false);
+ pNavigatorWin->mxToolbox->get_item_sensitive("previous"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("previous", false);
// Last
if (nState & NavState::BtnLastEnabled &&
- !pNavigatorWin->maToolbox->IsItemEnabled(nLastId))
- pNavigatorWin->maToolbox->EnableItem(nLastId);
+ !pNavigatorWin->mxToolbox->get_item_sensitive("last"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("last", true);
if (nState & NavState::BtnLastDisabled &&
- pNavigatorWin->maToolbox->IsItemEnabled(nLastId))
- pNavigatorWin->maToolbox->EnableItem(nLastId, false);
+ pNavigatorWin->mxToolbox->get_item_sensitive("last"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("last", false);
// Next
if (nState & NavState::BtnNextEnabled &&
- !pNavigatorWin->maToolbox->IsItemEnabled(nNextId))
- pNavigatorWin->maToolbox->EnableItem(nNextId);
+ !pNavigatorWin->mxToolbox->get_item_sensitive("next"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("next", true);
if (nState & NavState::BtnNextDisabled &&
- pNavigatorWin->maToolbox->IsItemEnabled(nNextId))
- pNavigatorWin->maToolbox->EnableItem(nNextId, false);
+ pNavigatorWin->mxToolbox->get_item_sensitive("next"))
+ pNavigatorWin->mxToolbox->set_item_sensitive("next", false);
if (nState & NavState::TableUpdate)
{
@@ -867,14 +750,14 @@ void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId,
const SfxStringItem& rStateItem = dynamic_cast<const SfxStringItem&>(*pItem);
const OUString& aPageName = rStateItem.GetValue();
- if( !pNavigatorWin->maTlbObjects->HasSelectedChildren( aPageName ) )
+ if( !pNavigatorWin->mxTlbObjects->HasSelectedChildren( aPageName ) )
{
- if( pNavigatorWin->maTlbObjects->GetSelectionMode() == SelectionMode::Multiple )
+ if (pNavigatorWin->mxTlbObjects->get_selection_mode() == SelectionMode::Multiple)
{
// because otherwise it is always additional select
- pNavigatorWin->maTlbObjects->SelectAll( false );
+ pNavigatorWin->mxTlbObjects->unselect_all();
}
- pNavigatorWin->maTlbObjects->SelectEntry( aPageName );
+ pNavigatorWin->mxTlbObjects->SelectEntry( aPageName );
}
}
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index b149354506b5..b27f8800932c 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -25,7 +25,6 @@
#include <sfx2/docfile.hxx>
#include <svx/svdoole2.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/builderfactory.hxx>
#include <cusshow.hxx>
#include <sfx2/viewfrm.hxx>
@@ -49,8 +48,6 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <svtools/acceleratorexecute.hxx>
#include <svtools/embedtransfer.hxx>
-#include <vcl/svlbitm.hxx>
-#include <vcl/treelistentry.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/processfactory.hxx>
#include <tools/diagnose_ex.h>
@@ -59,58 +56,38 @@
using namespace com::sun::star;
-class SdPageObjsTLB::IconProvider
-{
-public:
- IconProvider();
-
- // Regular icons.
- Image const maImgPage;
- Image const maImgPageExcl;
- Image const maImgPageObjsExcl;
- Image const maImgPageObjs;
- Image const maImgObjects;
- Image const maImgGroup;
-};
-
-bool SdPageObjsTLB::bIsInDrag = false;
+bool SdPageObjsTLV::bIsInDrag = false;
-bool SdPageObjsTLB::IsInDrag()
+bool SdPageObjsTLV::IsInDrag()
{
return bIsInDrag;
}
-SotClipboardFormatId SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = static_cast<SotClipboardFormatId>(SAL_MAX_UINT32);
+SotClipboardFormatId SdPageObjsTLV::SdPageObjsTransferable::mnListBoxDropFormatId = static_cast<SotClipboardFormatId>(SAL_MAX_UINT32);
-
-SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable(
- SdPageObjsTLB& rParent,
+SdPageObjsTLV::SdPageObjsTransferable::SdPageObjsTransferable(
const INetBookmark& rBookmark,
::sd::DrawDocShell& rDocShell,
NavigatorDragType eDragType)
: SdTransferable(rDocShell.GetDoc(), nullptr, true),
- mrParent( rParent ),
maBookmark( rBookmark ),
mrDocShell( rDocShell ),
meDragType( eDragType )
{
- rParent.SetupDragOrigin();
}
-VCL_BUILDER_FACTORY_CONSTRUCTOR(SdPageObjsTLB, WB_TABSTOP)
-
-SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable()
+SdPageObjsTLV::SdPageObjsTransferable::~SdPageObjsTransferable()
{
}
-void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats()
+void SdPageObjsTLV::SdPageObjsTransferable::AddSupportedFormats()
{
AddFormat(SotClipboardFormatId::NETSCAPE_BOOKMARK);
AddFormat(SotClipboardFormatId::TREELISTBOX);
AddFormat(GetListBoxDropFormatId());
}
-bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
+bool SdPageObjsTLV::SdPageObjsTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& /*rDestDoc*/ )
{
SotClipboardFormatId nFormatId = SotExchange::GetFormat( rFlavor );
switch (nFormatId)
@@ -131,17 +108,17 @@ bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const css::datatransfer::Da
}
}
-void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
+void SdPageObjsTLV::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction )
{
- mrParent.OnDragFinished();
+ SdPageObjsTLV::OnDragFinished();
SdTransferable::DragFinished(nDropAction);
}
-sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
+sal_Int64 SAL_CALL SdPageObjsTLV::SdPageObjsTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId )
{
sal_Int64 nRet;
- if( isUnoTunnelId<SdPageObjsTLB::SdPageObjsTransferable>(rId) )
+ if (isUnoTunnelId<SdPageObjsTLV::SdPageObjsTransferable>(rId))
{
nRet = static_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
}
@@ -156,21 +133,21 @@ namespace
class theSdPageObjsTLBUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdPageObjsTLBUnoTunnelId > {};
}
-const css::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()
+const css::uno::Sequence<sal_Int8>& SdPageObjsTLV::SdPageObjsTransferable::getUnoTunnelId()
{
return theSdPageObjsTLBUnoTunnelId::get().getSeq();
}
-SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData )
+SdPageObjsTLV::SdPageObjsTransferable* SdPageObjsTLV::SdPageObjsTransferable::getImplementation( const css::uno::Reference< css::uno::XInterface >& rxData )
throw()
{
try
{
css::uno::Reference< css::lang::XUnoTunnel > xUnoTunnel( rxData, css::uno::UNO_QUERY_THROW );
- return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>(
+ return reinterpret_cast<SdPageObjsTLV::SdPageObjsTransferable*>(
sal::static_int_cast<sal_uIntPtr>(
- xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) );
+ xUnoTunnel->getSomething( SdPageObjsTLV::SdPageObjsTransferable::getUnoTunnelId()) ) );
}
catch( const css::uno::Exception& )
{
@@ -178,455 +155,77 @@ SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::ge
return nullptr;
}
-SotClipboardFormatId SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId()
+SotClipboardFormatId SdPageObjsTLV::SdPageObjsTransferable::GetListBoxDropFormatId()
{
if (mnListBoxDropFormatId == static_cast<SotClipboardFormatId>(SAL_MAX_UINT32))
mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType("application/x-openoffice-treelistbox-moveonly;windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\"");
return mnListBoxDropFormatId;
}
-SdPageObjsTLB::SdPageObjsTLB( vcl::Window* pParentWin, WinBits nStyle )
-: SvTreeListBox ( pParentWin, nStyle )
-, mpDoc ( nullptr )
-, mpBookmarkDoc ( nullptr )
-, mpMedium ( nullptr )
-, mpOwnMedium ( nullptr )
-, maImgOle ( StockImage::Yes, BMP_OLE )
-, maImgGraphic ( StockImage::Yes, BMP_GRAPHIC )
-, mbLinkableSelected ( false )
-, mbSaveTreeItemState ( false )
-, mbShowAllShapes ( false )
-, mbShowAllPages ( false )
-, mbSelectionHandlerNavigates(false)
-, mbNavigationGrabsFocus(true)
-{
- // add lines to Tree-ListBox
- SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES |
- WB_HASBUTTONS | // WB_HASLINESATROOT |
- WB_HSCROLL |
- WB_HASBUTTONSATROOT );
- SetQuickSearch(true); /* i31275 */;
- SetNodeBitmaps(Image(StockImage::Yes, BMP_EXPAND), Image(StockImage::Yes, BMP_COLLAPSE));
-
- SetDragDropMode(
- DragDropMode::CTRL_MOVE | DragDropMode::CTRL_COPY |
- DragDropMode::APP_MOVE | DragDropMode::APP_COPY | DragDropMode::APP_DROP );
-
- m_pAccel = ::svt::AcceleratorExecute::createAcceleratorHelper();
-}
-
-void SdPageObjsTLB::SetSdNavigator(SdNavigatorWin* pNavigator)
-{
- mpNavigator = pNavigator;
-}
-
-void SdPageObjsTLB::SetViewFrame( const SfxViewFrame* pViewFrame )
-{
- sd::ViewShellBase* pBase = sd::ViewShellBase::GetViewShellBase(pViewFrame);
- const css::uno::Reference< css::frame::XFrame > xFrame = pBase->GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
- m_pAccel->init(::comphelper::getProcessComponentContext(), xFrame);
-}
-
-
-SdPageObjsTLB::~SdPageObjsTLB()
-{
- disposeOnce();
-}
-
-void SdPageObjsTLB::dispose()
-{
- if ( mpBookmarkDoc )
- CloseBookmarkDoc();
- else
- // no document was created from mpMedium, so this object is still the owner of it
- delete mpMedium;
- mpNavigator.clear();
- m_pAccel.reset();
- SvTreeListBox::dispose();
-}
-
-// helper function for GetEntryAltText and GetEntryLongDescription
-OUString SdPageObjsTLB::getAltLongDescText(SvTreeListEntry* pEntry , bool isAltText) const
-{
- sal_uInt16 maxPages = mpDoc->GetPageCount();
- sal_uInt16 pageNo;
- SdrObject* pObj = nullptr;
-
- OUString ParentName = GetEntryText( GetRootLevelParent( pEntry ) );
-
- for( pageNo = 0; pageNo < maxPages; pageNo++ )
- {
- const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetPage( pageNo ) );
- if( pPage->GetPageKind() != PageKind::Standard ) continue;
- if( pPage->GetName() != ParentName ) continue;
- SdrObjListIter aIter( pPage, SdrIterMode::Flat );
- while( aIter.IsMore() )
- {
- pObj = aIter.Next();
- if( GetEntryText(pEntry) == GetObjectName( pObj ) )
- {
- if( isAltText )
- return pObj->GetTitle();
- else
- return pObj->GetDescription();
- }
- }
- }
- return OUString();
-
-}
-
-OUString SdPageObjsTLB::GetEntryAltText( SvTreeListEntry* pEntry ) const
-{
- return getAltLongDescText( pEntry, true );
-}
-
-OUString SdPageObjsTLB::GetEntryLongDescription( SvTreeListEntry* pEntry ) const
-{
- return getAltLongDescText( pEntry, false);
-}
-
-void SdPageObjsTLB::InitEntry(SvTreeListEntry* pEntry,
- const OUString& rStr, const Image& rImg1, const Image& rImg2)
-{
- sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
- SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2 );
- SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nColToHilite ));
- pEntry->ReplaceItem(std::make_unique<SvLBoxString>(rCol.GetText()), nColToHilite );
-}
-
-void SdPageObjsTLB::SaveExpandedTreeItemState(SvTreeListEntry* pEntry, std::vector<OUString>& vectTreeItem)
-{
- if (!pEntry)
- return;
-
- SvTreeListEntry* pListEntry = pEntry;
- while (pListEntry)
- {
- if (pListEntry->HasChildren())
- {
- if (IsExpanded(pListEntry))
- vectTreeItem.push_back(GetEntryText(pListEntry));
- SvTreeListEntry* pChildEntry = FirstChild(pListEntry);
- SaveExpandedTreeItemState(pChildEntry, vectTreeItem);
- }
- pListEntry = pListEntry->NextSibling();
- }
-}
-void SdPageObjsTLB::Clear()
-{
- //Save the expanded tree item
- if (mbSaveTreeItemState)
- {
- maSelectionEntryText.clear();
- maTreeItem.clear();
- if (GetCurEntry())
- maSelectionEntryText = GetSelectedEntry();
- SvTreeListEntry* pEntry = FirstChild(nullptr);
- SaveExpandedTreeItemState(pEntry, maTreeItem);
- }
- return SvTreeListBox::Clear();
-}
-
-OUString SdPageObjsTLB::GetObjectName(
- const SdrObject* pObject,
- const bool bCreate) const
-{
- OUString aRet;
-
- if ( pObject )
- {
- aRet = pObject->GetName();
-
- if (aRet.isEmpty() && dynamic_cast<const SdrOle2Obj* >(pObject) != nullptr)
- aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
- }
-
- if (bCreate
- && mbShowAllShapes
- && aRet.isEmpty()
- && pObject!=nullptr)
- {
- aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME);
- aRet = aRet.replaceFirst("%1", OUString::number(pObject->GetOrdNum() + 1));
- }
-
- return aRet;
-}
-
-/**
- * select an entry in TreeLB
- */
-bool SdPageObjsTLB::SelectEntry( const OUString& rName )
-{
- bool bFound = false;
-
- if( !rName.isEmpty() )
- {
- SvTreeListEntry* pEntry = nullptr;
- OUString aTmp;
-
- for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
- {
- aTmp = GetEntryText( pEntry );
- if( aTmp == rName )
- {
- bFound = true;
- SetCurEntry( pEntry );
- }
- }
- }
- return bFound;
-}
-
/**
* @return true if children of the specified string are selected
*/
-bool SdPageObjsTLB::HasSelectedChildren( const OUString& rName )
+bool SdPageObjsTLV::HasSelectedChildren( const OUString& rName )
{
bool bChildren = false;
if( !rName.isEmpty() )
{
- bool bFound = false;
- SvTreeListEntry* pEntry = nullptr;
+ std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
OUString aTmp;
- for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) )
+ if (m_xTreeView->get_iter_first(*xEntry))
{
- aTmp = GetEntryText( pEntry );
- if( aTmp == rName )
+ do
{
- bFound = true;
- bool bExpanded = IsExpanded( pEntry );
- long nCount = GetChildSelectionCount( pEntry );
- if( bExpanded && nCount > 0 )
- bChildren = true;
- }
- }
- }
- return bChildren;
-}
-
-/**
- * Fill TreeLB with pages and objects
- */
-void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, bool bAllPages,
- const OUString& rDocName)
-{
- OUString aSelection;
- if( GetSelectionCount() > 0 )
- {
- aSelection = GetSelectedEntry();
- Clear();
- }
-
- mpDoc = pInDoc;
- maDocName = rDocName;
- mbShowAllPages = bAllPages;
- mpMedium = nullptr;
-
- IconProvider aIconProvider;
-
- // first insert all pages including objects
- sal_uInt16 nPage = 0;
- const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
-
- while( nPage < nMaxPages )
- {
- const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetPage( nPage ) );
- if( (mbShowAllPages || pPage->GetPageKind() == PageKind::Standard)
- && (pPage->GetPageKind() != PageKind::Handout) ) //#94954# never list the normal handout page ( handout-masterpage is used instead )
- {
- bool bPageExluded = pPage->IsExcluded();
-
- bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage);
- bPageExluded |= !bPageBelongsToShow;
-
- AddShapeList(*pPage, nullptr, pPage->GetName(), bPageExluded, nullptr, aIconProvider);
- }
- nPage++;
- }
-
- // then insert all master pages including objects
- if( mbShowAllPages )
- {
- nPage = 0;
- const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
-
- while( nPage < nMaxMasterPages )
- {
- const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetMasterPage( nPage ) );
- AddShapeList(*pPage, nullptr, pPage->GetName(), false, nullptr, aIconProvider);
- nPage++;
- }
- }
- if( !aSelection.isEmpty() )
- SelectEntry( aSelection );
- else if (mbSaveTreeItemState && !maSelectionEntryText.isEmpty())
- {
- SelectEntry(maSelectionEntryText);
- }
-}
-
-/**
- * We insert only the first entry. Children are created on demand.
- */
-void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium,
- const OUString& rDocName )
-{
- mpDoc = pInDoc;
-
- // this object now owns the Medium
- mpMedium = pInMedium;
- maDocName = rDocName;
-
- Image aImgDocOpen(StockImage::Yes, BMP_DOC_OPEN);
- Image aImgDocClosed(StockImage::Yes, BMP_DOC_CLOSED);
-
- // insert document name
- InsertEntry( maDocName, aImgDocOpen, aImgDocClosed, nullptr, true, TREELIST_APPEND,
- reinterpret_cast< void* >( 1 )
- );
-}
-
-void SdPageObjsTLB::AddShapeList (
- const SdrObjList& rList,
- SdrObject* pShape,
- const OUString& rsName,
- const bool bIsExcluded,
- SvTreeListEntry* pParentEntry,
- const IconProvider& rIconProvider)
-{
- Image aIcon (rIconProvider.maImgPage);
- if (bIsExcluded)
- aIcon = rIconProvider.maImgPageExcl;
- else if (pShape != nullptr)
- aIcon = rIconProvider.maImgGroup;
-
- void* pUserData (reinterpret_cast<void*>(1));
- if (pShape != nullptr)
- pUserData = pShape;
-
- SvTreeListEntry* pEntry = InsertEntry(
- rsName,
- aIcon,
- aIcon,
- pParentEntry,
- false,
- TREELIST_APPEND,
- pUserData);
-
- SdrObjListIter aIter(
- &rList,
- !rList.HasObjectNavigationOrder() /* use navigation order, if available */,
- SdrIterMode::Flat);
-
- while( aIter.IsMore() )
- {
- SdrObject* pObj = aIter.Next();
- OSL_ASSERT(pObj!=nullptr);
+ aTmp = m_xTreeView->get_text(*xEntry);
+ if (aTmp == rName)
+ {
- // Get the shape name.
- OUString aStr (GetObjectName( pObj ) );
+ // see if any of the selected nodes are subchildren of this node
+ m_xTreeView->selected_foreach([this, &bChildren, &xEntry](weld::TreeIter& rEntry){
+ std::unique_ptr<weld::TreeIter> xParent(m_xTreeView->make_iterator(&rEntry));
+ while (!bChildren && m_xTreeView->iter_parent(*xParent))
+ bChildren = m_xTreeView->iter_compare(*xParent, *xEntry) == 0;
+ return bChildren;
+ });
- if( !aStr.isEmpty() )
- {
- if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_OLE2 )
- {
- InsertEntry(
- aStr,
- maImgOle,
- maImgOle,
- pEntry,
- false,
- TREELIST_APPEND,
- pObj
- );
- }
- else if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_GRAF )
- {
- InsertEntry(
- aStr,
- maImgGraphic,
- maImgGraphic,
- pEntry,
- false,
- TREELIST_APPEND,
- pObj
- );
- }
- else if (pObj->IsGroupObject())
- {
- AddShapeList(
- *pObj->GetSubList(),
- pObj,
- aStr,
- false,
- pEntry,
- rIconProvider
- );
- }
- else
- {
- InsertEntry(
- aStr,
- rIconProvider.maImgObjects,
- rIconProvider.maImgObjects,
- pEntry,
- false,
- TREELIST_APPEND,
- pObj
- );
+ break;
+ }
}
+ while (m_xTreeView->iter_next(*xEntry));
}
}
- if( !pEntry->HasChildren() )
- return;
-
- SetExpandedEntryBmp(
- pEntry,
- bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
- SetCollapsedEntryBmp(
- pEntry,
- bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs);
- if (mbSaveTreeItemState)
- {
- OUString strEntry = GetEntryText(pEntry);
- auto it = std::find(maTreeItem.begin(), maTreeItem.end(), strEntry);
- if (it != maTreeItem.end())
- Expand( pEntry );
- }
- else
- Expand( pEntry );
+ return bChildren;
}
-void SdPageObjsTLB::SetShowAllShapes (
+void SdPageObjsTLV::SetShowAllShapes (
const bool bShowAllShapes,
const bool bFillList)
{
- mbShowAllShapes = bShowAllShapes;
+ m_bShowAllShapes = bShowAllShapes;
if (bFillList)
{
- if (mpMedium == nullptr)
- Fill(mpDoc, mbShowAllPages, maDocName);
+ if (m_pMedium == nullptr)
+ Fill(m_pDoc, m_bShowAllPages, m_aDocName);
else
- Fill(mpDoc, mpMedium, maDocName);
+ Fill(m_pDoc, m_pMedium, m_aDocName);
}
}
-bool SdPageObjsTLB::IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjList& rList,
+bool SdPageObjsTLV::IsEqualToShapeList(std::unique_ptr<weld::TreeIter>& rEntry, const SdrObjList& rList,
const OUString& rListName)
{
- if (!pEntry)
+ if (!rEntry)
return false;
- OUString aName = GetEntryText(pEntry);
+ OUString aName = m_xTreeView->get_text(*rEntry);
if (rListName != aName)
return false;
- pEntry = Next(pEntry);
+ if (!m_xTreeView->iter_next(*rEntry))
+ rEntry.reset();
SdrObjListIter aIter(&rList,
!rList.HasObjectNavigationOrder() /* use navigation order, if available */,
@@ -640,400 +239,184 @@ bool SdPageObjsTLB::IsEqualToShapeList(SvTreeListEntry*& pEntry, const SdrObjLis
if (!aObjectName.isEmpty())
{
- if (!pEntry)
+ if (!rEntry)
return false;
- aName = GetEntryText(pEntry);
+ aName = m_xTreeView->get_text(*rEntry);
if (aObjectName != aName)
return false;
if (pObj->IsGroupObject())
{
- bool bRet = IsEqualToShapeList(pEntry, *pObj->GetSubList(), aObjectName);
+ bool bRet = IsEqualToShapeList(rEntry, *pObj->GetSubList(), aObjectName);
if (!bRet)
return false;
}
else
- pEntry = Next(pEntry);
- }
- }
-
- return true;
-}
-
-/**
- * Checks if the pages (PageKind::Standard) of a doc and the objects on the pages
- * are identical to the TreeLB.
- * If a doc is provided, this will be the used doc (important by more than
- * one document).
- */
-bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc )
-{
- if( pInDoc )
- mpDoc = pInDoc;
-
- if( !mpDoc )
- return false;
-
- SvTreeListEntry* pEntry = First();
-
- // compare all pages including the objects
- sal_uInt16 nPage = 0;
- const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
-
- while( nPage < nMaxPages )
- {
- const SdPage* pPage = static_cast<const SdPage*>( mpDoc->GetPage( nPage ) );
- if( pPage->GetPageKind() == PageKind::Standard )
- {
- bool bRet = IsEqualToShapeList(pEntry, *pPage, pPage->GetName());
- if (!bRet)
- return false;
- }
- nPage++;
- }
- // If there are still entries in the listbox,
- // then objects (with names) or pages were deleted
- return !pEntry;
-}
-
-/**
- * @return selected string
- */
-OUString SdPageObjsTLB::GetSelectedEntry() const
-{
- return GetEntryText( GetCurEntry() );
-}
-
-/**
- * Entries are inserted only by request (double click)
- */
-void SdPageObjsTLB::RequestingChildren( SvTreeListEntry* pFileEntry )
-{
- if( !pFileEntry->HasChildren() )
- {
- if( GetBookmarkDoc() )
- {
- SdrObject* pObj = nullptr;
- SvTreeListEntry* pPageEntry = nullptr;
-
- Image aImgPage(StockImage::Yes, BMP_PAGE);
- Image aImgPageObjs(StockImage::Yes, BMP_PAGEOBJS);
- Image aImgObjects(StockImage::Yes, BMP_OBJECTS);
-
- // document name already inserted
-
- // only insert all "normal" ? slides with objects
- sal_uInt16 nPage = 0;
- const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount();
-
- while( nPage < nMaxPages )
{
- SdPage* pPage = static_cast<SdPage*>( mpBookmarkDoc->GetPage( nPage ) );
- if( pPage->GetPageKind() == PageKind::Standard )
- {
- pPageEntry = InsertEntry( pPage->GetName(),
- aImgPage,
- aImgPage,
- pFileEntry,
- false,
- TREELIST_APPEND,
- reinterpret_cast< void* >( 1 ) );
-
- SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
-
- while( aIter.IsMore() )
- {
- pObj = aIter.Next();
- OUString aStr( GetObjectName( pObj ) );
- if( !aStr.isEmpty() )
- {
- if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_OLE2 )
- {
- InsertEntry(aStr, maImgOle, maImgOle, pPageEntry);
- }
- else if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_GRAF )
- {
- InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry);
- }
- else
- {
- InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry);
- }
- }
- }
- if( pPageEntry->HasChildren() )
- {
- SetExpandedEntryBmp( pPageEntry, aImgPageObjs );
- SetCollapsedEntryBmp( pPageEntry, aImgPageObjs );
- }
- }
- nPage++;
+ if (!m_xTreeView->iter_next(*rEntry))
+ rEntry.reset();
}
}
}
- else
- SvTreeListBox::RequestingChildren( pFileEntry );
-}
-
-/**
- * Checks if it is a draw file and opens the BookmarkDoc depending of
- * the provided Docs
- */
-SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed)
-{
- if (
- !mpBookmarkDoc ||
- (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName()))
- )
- {
- // create a new BookmarkDoc if now one exists or if a new Medium is provided
- if (mpOwnMedium != pMed)
- {
- CloseBookmarkDoc();
- }
-
- if (pMed)
- {
- // it looks that it is undefined if a Medium was set by Fill() already
- DBG_ASSERT( !mpMedium, "SfxMedium confusion!" );
- delete mpMedium;
- mpMedium = nullptr;
-
- // take over this Medium (currently used only be Navigator)
- mpOwnMedium = pMed;
- }
-
- DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" );
-
- if( pMed )
- {
- // in this mode the document is also owned and controlled by this instance
- mxBookmarkDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::STANDARD, true, DocumentType::Impress);
- if (mxBookmarkDocShRef->DoLoad(pMed))
- mpBookmarkDoc = mxBookmarkDocShRef->GetDoc();
- else
- mpBookmarkDoc = nullptr;
- }
- else if ( mpMedium )
- // in this mode the document is owned and controlled by the SdDrawDocument
- // it can be released by calling the corresponding CloseBookmarkDoc method
- // successful creation of a document makes this the owner of the medium
- mpBookmarkDoc = const_cast<SdDrawDocument*>(mpDoc)->OpenBookmarkDoc(mpMedium);
-
- if ( !mpBookmarkDoc )
- {
- std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Warning, VclButtonsType::Ok, SdResId(STR_READ_DATA_ERROR)));
- xErrorBox->run();
- mpMedium = nullptr; //On failure the SfxMedium is invalid
- }
- }
- return mpBookmarkDoc;
+ return true;
}
/**
- * Close and delete bookmark document
+ * Checks if the pages (PageKind::Standard) of a doc and the objects on the pages
+ * are identical to the TreeLB.
+ * If a doc is provided, this will be the used doc (important by more than
+ * one document).
*/
-void SdPageObjsTLB::CloseBookmarkDoc()
+bool SdPageObjsTLV::IsEqualToDoc( const SdDrawDocument* pInDoc )
{
- if (mxBookmarkDocShRef.is())
- {
- mxBookmarkDocShRef->DoClose();
- mxBookmarkDocShRef.clear();
-
- // Medium is owned by document, so it's destroyed already
- mpOwnMedium = nullptr;
- }
- else if ( mpBookmarkDoc )
- {
- DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" );
- if ( mpDoc )
- {
- // The document owns the Medium, so the Medium will be invalid after closing the document
- const_cast<SdDrawDocument*>(mpDoc)->CloseBookmarkDoc();
- mpMedium = nullptr;
- }
- }
- else
- {
- // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc
- delete mpOwnMedium;
- mpOwnMedium = nullptr;
- }
+ if( pInDoc )
+ m_pDoc = pInDoc;
- mpBookmarkDoc = nullptr;
-}
+ if( !m_pDoc )
+ return false;
-void SdPageObjsTLB::SelectHdl()
-{
- SvTreeListEntry* pEntry = FirstSelected();
+ std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator());
+ if (!m_xTreeView->get_iter_first(*xEntry))
+ xEntry.reset();
- mbLinkableSelected = true;
+ // compare all pages including the objects
+ sal_uInt16 nPage = 0;
+ const sal_uInt16 nMaxPages = m_pDoc->GetPageCount();
- while( pEntry && mbLinkableSelected )
+ while( nPage < nMaxPages )
{
- if( nullptr == pEntry->GetUserData() )
- mbLinkableSelected = false;
-
- pEntry = NextSelected( pEntry );
+ const SdPage* pPage = static_cast<const SdPage*>( m_pDoc->GetPage( nPage ) );
+ if( pPage->GetPageKind() == PageKind::Standard )
+ {
+ bool bRet = IsEqualToShapeList(xEntry, *pPage, pPage->GetName());
+ if (!bRet)
+ return false;
+ }
+ nPage++;
}
-
- SvTreeListBox::SelectHdl();
-
- if (mbSelectionHandlerNavigates)
- DoubleClickHdl();
+ // If there are still entries in the listbox,
+ // then objects (with names) or pages were deleted
+ return !xEntry;
}
-/**
- * Overloads RETURN with the functionality of DoubleClick
- */
-void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt )
+IMPL_LINK(SdPageObjsTLV, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
- const vcl::KeyCode& aKeyCode = rKEvt.GetKeyCode();
- if ( m_pAccel->execute( aKeyCode ) )
- // the accelerator consumed the event
- return;
- if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN )
+ const vcl::KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if (m_xAccel->execute(rKeyCode))
{
- // commented code from svtools/source/contnr/svimpbox.cxx
- SvTreeListEntry* pCursor = GetCurEntry();
- if (!pCursor)
- return;
- if( pCursor->HasChildren() || pCursor->HasChildrenOnDemand() )
- {
- if( IsExpanded( pCursor ) )
- Collapse( pCursor );
- else
- Expand( pCursor );
- }
-
- DoubleClickHdl();
+ // the accelerator consumed the event
+ return true;
}
- else if (rKEvt.GetKeyCode().GetCode() == KEY_SPACE)
+ if (rKeyCode.GetCode() == KEY_RETURN)
{
- if (mpNavigator)
+ std::unique_ptr<weld::TreeIter> xCursor(m_xTreeView->make_iterator());
+ if (m_xTreeView->get_cursor(xCursor.get()))
{
- SvTreeListEntry* pNewEntry = GetCurEntry();
- if (!pNewEntry)
- return;
- SvTreeListEntry* pParentEntry = GetParent(pNewEntry);
- if (!pParentEntry)
- return;
- Invalidate();
+ if (m_xTreeView->get_row_expanded(*xCursor))
+ m_xTreeView->collapse_row(*xCursor);
+ else
+ m_xTreeView->expand_row(*xCursor);
}
+ m_aRowActivatedHdl.Call(*m_xTreeView);
+ return true;
}
- else
- SvTreeListBox::KeyInput( rKEvt );
+ return false;
}
-void SdPageObjsTLB::MouseButtonDown(const MouseEvent& rMEvt)
+IMPL_LINK(SdPageObjsTLV, MousePressHdl, const MouseEvent&, rMEvt, bool)
{
- mbSelectionHandlerNavigates = rMEvt.GetClicks() == 1;
- comphelper::ScopeGuard aNavigationGuard([this]() { this->mbSelectionHandlerNavigates = false; });
- mbNavigationGrabsFocus = rMEvt.GetClicks() != 1;
- comphelper::ScopeGuard aGrabGuard([this]() { this->mbNavigationGrabsFocus = true; });
+ m_bSelectionHandlerNavigates = rMEvt.GetClicks() == 1;
+ m_bNavigationGrabsFocus = rMEvt.GetClicks() != 1;
+ return false;
+}
- SvTreeListBox::MouseButtonDown(rMEvt);
+IMPL_LINK_NOARG(SdPageObjsTLV, MouseReleaseHdl, const MouseEvent&, bool)
+{
+ m_bSelectionHandlerNavigates = false;
+ m_bNavigationGrabsFocus = true;
+ return false;
}
-/**
- * StartDrag-Request
- */
-void SdPageObjsTLB::StartDrag( sal_Int8, const Point& rPosPixel)
+IMPL_LINK_NOARG(SdPageObjsTLV, DragBeginHdl, weld::TreeView&, bool)
{
- SvTreeListEntry* pEntry = GetEntry(rPosPixel);
+ return StartDrag();
+}
- if (!(pEntry && mpNavigator && mpNavigator->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE))
- return;
+namespace
+{
+ bool CanDragSource(weld::TreeView& rTreeView)
+ {
+ std::unique_ptr<weld::TreeIter> xSource(rTreeView.make_iterator());
+ if (!rTreeView.get_selected(xSource.get()))
+ return false;
- // Mark only the children of the page under the mouse as drop
- // targets. This prevents moving shapes from one page to another.
+ std::unique_ptr<weld::TreeIter> xSourceParent(rTreeView.make_iterator(xSource.get()));
+ bool bSourceHasParent = rTreeView.iter_parent(*xSourceParent);
+ // level 1 objects only
+ if (!bSourceHasParent || rTreeView.get_iter_depth(*xSourceParent))
+ return false;
- // Select all entries and disable them as drop targets.
- SetSelectionMode(SelectionMode::Multiple);
- SetCursor(static_cast<SvTreeListEntry*>(nullptr));
- SelectAll(true, false);
- EnableSelectionAsDropTarget(false);
+ SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(rTreeView.get_id(*xSource).toInt64());
+ if (pSourceObject == reinterpret_cast<SdrObject*>(1))
+ pSourceObject = nullptr;
- // Enable only the entries as drop targets that are children of the
- // page under the mouse.
- SvTreeListEntry* pParent = GetRootLevelParent(pEntry);
- if (pParent != nullptr)
- {
- SelectAll(false, false);
- Select(pParent);
- // for (SvTreeListEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild))
- // Select(pChild, sal_True);
- EnableSelectionAsDropTarget();//sal_False);
- }
+ if (!pSourceObject)
+ return false;
- // Set selection back to the entry under the mouse.
- SelectAll(false, false);
- SetSelectionMode(SelectionMode::Single);
- Select(pEntry);
+ SdrPage* pObjectList = pSourceObject->getSdrPageFromSdrObject();
+ if (!pObjectList)
+ return false;
- // We can delete the Navigator from ExecuteDrag (when switching to
- // another document type), but that would kill the StarView MouseMove
- // Handler which is calling Command().
- // For this reason, Drag&Drop is asynchronous.
- Application::PostUserEvent( LINK( this, SdPageObjsTLB, ExecDragHdl ), nullptr, true );
+ return true;
+ }
}
/**
- * Begin drag
+ * StartDrag-Request
*/
-void SdPageObjsTLB::DoDrag()
+bool SdPageObjsTLV::StartDrag()
{
- if (!mpNavigator)
- return;
-
- ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
- OUString aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INetProtocol::File ).GetMainURL( INetURLObject::DecodeMechanism::NONE );
- NavigatorDragType eDragType = mpNavigator->GetNavigatorDragType();
-
- aURL += "#" + GetSelectedEntry();
-
- INetBookmark aBookmark( aURL, GetSelectedEntry() );
- sal_Int8 nDNDActions = DND_ACTION_COPYMOVE;
-
- if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
- nDNDActions = DND_ACTION_LINK; // Either COPY *or* LINK, never both!
- else if (mpDoc->GetSdPageCount(PageKind::Standard) == 1)
- {
- // Can not move away the last slide in a document.
- nDNDActions = DND_ACTION_COPY;
- }
+ return !CanDragSource(*m_xTreeView) || DoDrag();
+}
- SvTreeListBox::ReleaseMouse();
+/**
+ * Begin drag
+ */
+bool SdPageObjsTLV::DoDrag()
+{
+ if (!m_xNavigator)
+ return true;
- bIsInDrag = true;
+ if (!m_xHelper)
+ return true;
// Get the view.
+ ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell);
if (pViewShell == nullptr)
{
OSL_ASSERT(pViewShell!=nullptr);
- return;
+ return true;
}
sd::View* pView = pViewShell->GetView();
if (pView == nullptr)
{
OSL_ASSERT(pView!=nullptr);
- return;
+ return true;
}
- // object is destroyed by internal reference mechanism
- SdTransferable* pTransferable =
- new SdPageObjsTLB::SdPageObjsTransferable(
- *this, aBookmark, *pDocShell, eDragType);
+ bIsInDrag = true;
+
+ std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
+ bool bUserData = m_xTreeView->get_cursor(xEntry.get());
SdrObject* pObject = nullptr;
- void* pUserData = GetCurEntry()->GetUserData();
- if (pUserData != nullptr && pUserData != reinterpret_cast<void*>(1))
- pObject = static_cast<SdrObject*>(pUserData);
+ sal_Int64 nUserData = bUserData ? m_xTreeView->get_id(*xEntry).toInt64() : 0;
+ if (nUserData != 1)
+ pObject = reinterpret_cast<SdrObject*>(nUserData);
if (pObject != nullptr)
{
// For shapes without a user supplied name (the automatically
@@ -1041,9 +424,9 @@ void SdPageObjsTLB::DoDrag()
// is used.
if (GetObjectName(pObject, false).isEmpty())
{
- AddShapeToTransferable(*pTransferable, *pObject);
- pTransferable->SetView(pView);
- SD_MOD()->pTransferDrag = pTransferable;
+ AddShapeToTransferable(*m_xHelper, *pObject);
+ m_xHelper->SetView(pView);
+ SD_MOD()->pTransferDrag = m_xHelper.get();
}
// Unnamed shapes have to be selected to be recognized by the
@@ -1056,122 +439,78 @@ void SdPageObjsTLB::DoDrag()
}
else
{
- pTransferable->SetView(pView);
- SD_MOD()->pTransferDrag = pTransferable;
+ m_xHelper->SetView(pView);
+ SD_MOD()->pTransferDrag = m_xHelper.get();
}
- pTransferable->StartDrag( this, nDNDActions );
+ return false;
}
-void SdPageObjsTLB::OnDragFinished()
+void SdPageObjsTLV::OnDragFinished()
{
- if (mpNavigator)
- {
- MouseEvent aMEvt(mpNavigator->GetPointerPosPixel());
- SvTreeListBox::MouseButtonUp(aMEvt);
- }
-
bIsInDrag = false;
}
+SdPageObjsTLVDropTarget::SdPageObjsTLVDropTarget(weld::TreeView& rTreeView)
+ : DropTargetHelper(rTreeView.get_drop_target())
+ , m_rTreeView(rTreeView)
+{
+}
+
/**
* AcceptDrop-Event
*/
-sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent)
+sal_Int8 SdPageObjsTLVDropTarget::AcceptDrop(const AcceptDropEvent& rEvt)
{
- sal_Int8 nResult (DND_ACTION_NONE);
+ weld::TreeView* pSource = m_rTreeView.get_drag_source();
+ // only dragging within the same widget allowed
+ if (!pSource || pSource != &m_rTreeView)
+ return DND_ACTION_NONE;
- SvTreeListEntry* pEntry = GetDropTarget(rEvent.maPosPixel);
- if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction ))
- {
- ImplShowTargetEmphasis( pTargetEntry, false );
- }
- else if( GetDragDropMode() == DragDropMode::NONE )
- {
- SAL_WARN( "sc.ui", "SdPageObjsTLB::AcceptDrop(): no target" );
- }
- else if (IsDropAllowed(pEntry))
- {
- nResult = DND_ACTION_MOVE;
+ std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
+ if (!m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get()))
+ return DND_ACTION_NONE;
- // Draw emphasis.
- if (pEntry != pTargetEntry || !(nImpFlags & SvTreeListBoxFlags::TARGEMPH_VIS))
- {
- ImplShowTargetEmphasis( pTargetEntry, false );
- pTargetEntry = pEntry;
- ImplShowTargetEmphasis( pTargetEntry, true );
- }
- }
+ std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
+ if (!m_rTreeView.get_selected(xSource.get()))
+ return DND_ACTION_NONE;
- // Hide emphasis when there is no valid drop action.
- if (nResult == DND_ACTION_NONE)
- ImplShowTargetEmphasis(pTargetEntry, false);
+ std::unique_ptr<weld::TreeIter> xTargetParent(m_rTreeView.make_iterator(xTarget.get()));
+ while (m_rTreeView.get_iter_depth(*xTargetParent))
+ m_rTreeView.iter_parent(*xTargetParent);
- return nResult;
-}
+ std::unique_ptr<weld::TreeIter> xSourceParent(m_rTreeView.make_iterator(xSource.get()));
+ while (m_rTreeView.get_iter_depth(*xSourceParent))
+ m_rTreeView.iter_parent(*xSourceParent);
-/**
- * ExecuteDrop-Event
- */
-sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt )
-{
- SvTreeListBox::ExecuteDrop(rEvt, this);
- return DND_ACTION_NONE;
+ // can only drop within the same page
+ if (m_rTreeView.iter_compare(*xTargetParent, *xSourceParent) != 0)
+ return DND_ACTION_NONE;
+
+ return DND_ACTION_MOVE;
}
/**
- * Handler for Dragging
+ * ExecuteDrop-Event
*/
-IMPL_LINK_NOARG(SdPageObjsTLB, ExecDragHdl, void*, void)
-{
- // as link, then it is allowed to asynchronous, without ImpMouseMoveMsg on
- // the stack, delete the Navigator
- DoDrag();
-}
-
-bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const
+sal_Int8 SdPageObjsTLVDropTarget::ExecuteDrop( const ExecuteDropEvent& rEvt )
{
- // Return <TRUE/> as default when there is no custom show or when none
- // is used. The page does then belong to the standard show.
- bool bBelongsToShow = true;
-
- if (mpDoc->getPresentationSettings().mbCustomShow)
- {
- // Get the current custom show.
- SdCustomShow* pCustomShow = nullptr;
- SdCustomShowList* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList();
- if (pShowList != nullptr)
- {
- sal_uLong nCurrentShowIndex = pShowList->GetCurPos();
- pCustomShow = (*pShowList)[nCurrentShowIndex].get();
- }
-
- // Check whether the given page is part of that custom show.
- if (pCustomShow != nullptr)
- {
- bBelongsToShow = false;
- size_t nPageCount = pCustomShow->PagesVector().size();
- for (size_t i=0; i<nPageCount && !bBelongsToShow; i++)
- if (pPage == pCustomShow->PagesVector()[i])
- bBelongsToShow = true;
- }
- }
+ weld::TreeView* pSource = m_rTreeView.get_drag_source();
+ // only dragging within the same widget allowed
+ if (!pSource || pSource != &m_rTreeView)
+ return DND_ACTION_NONE;
- return bBelongsToShow;
-}
+ std::unique_ptr<weld::TreeIter> xSource(m_rTreeView.make_iterator());
+ if (!m_rTreeView.get_selected(xSource.get()))
+ return DND_ACTION_NONE;
-TriState SdPageObjsTLB::NotifyMoving(
- SvTreeListEntry* pTarget,
- SvTreeListEntry* pEntry,
- SvTreeListEntry*& rpNewParent,
- sal_uLong& rNewChildPos)
-{
- SvTreeListEntry* pDestination = pTarget;
- while (GetParent(pDestination) != nullptr && GetParent(GetParent(pDestination)) != nullptr)
- pDestination = GetParent(pDestination);
+ std::unique_ptr<weld::TreeIter> xTarget(m_rTreeView.make_iterator());
+ if (!m_rTreeView.get_dest_row_at_pos(rEvt.maPosPixel, xTarget.get()))
+ return DND_ACTION_NONE;
+ int nTargetPos = m_rTreeView.get_iter_index_in_parent(*xTarget) + 1;
- SdrObject* pTargetObject = static_cast<SdrObject*>(pDestination->GetUserData());
- SdrObject* pSourceObject = static_cast<SdrObject*>(pEntry->GetUserData());
+ SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(m_rTreeView.get_id(*xTarget).toInt64());
+ SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(m_rTreeView.get_id(*xSource).toInt64());
if (pSourceObject == reinterpret_cast<SdrObject*>(1))
pSourceObject = nullptr;
@@ -1182,80 +521,25 @@ TriState SdPageObjsTLB::NotifyMoving(
{
sal_uInt32 nNewPosition;
if (pTargetObject == reinterpret_cast<SdrObject*>(1))
+ {
nNewPosition = 0;
+ nTargetPos = 0;
+ }
else
nNewPosition = pTargetObject->GetNavigationPosition() + 1;
pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition);
}
- // Update the tree list.
- if (GetParent(pDestination) == nullptr)
- {
- rpNewParent = pDestination;
- rNewChildPos = 0;
- }
- else
- {
- rpNewParent = GetParent(pDestination);
- rNewChildPos = SvTreeList::GetRelPos(pDestination) + 1;
- rNewChildPos += nCurEntrySelPos;
- nCurEntrySelPos++;
- }
- return TRISTATE_TRUE;
- }
- else
- return TRISTATE_FALSE;
-}
-
-SvTreeListEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation)
-{
- SvTreeListEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation);
- if (pEntry == nullptr)
- return nullptr;
+ std::unique_ptr<weld::TreeIter> xSourceParent(m_rTreeView.make_iterator(xSource.get()));
+ m_rTreeView.iter_parent(*xSourceParent);
- if (GetParent(pEntry) == nullptr)
- {
- // Use page entry as insertion position.
- }
- else
- {
- // Go to second hierarchy level, i.e. top level shapes,
- // i.e. children of pages.
- while (GetParent(pEntry) != nullptr && GetParent(GetParent(pEntry)) != nullptr)
- pEntry = GetParent(pEntry);
-
- // Advance to next sibling.
- SvTreeListEntry* pNext;
- sal_uInt16 nDepth (0);
- do
- {
- pNext = NextVisible(pEntry, &nDepth);
- if (pNext != nullptr && nDepth > 0 && nDepth!=0xffff)
- pEntry = pNext;
- else
- break;
- }
- while (pEntry != nullptr);
+ m_rTreeView.move_subtree(*xSource, xSourceParent.get(), nTargetPos);
}
- return pEntry;
-}
-
-bool SdPageObjsTLB::IsDropAllowed (SvTreeListEntry const * pEntry)
-{
- if (pEntry == nullptr)
- return false;
-
- if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId()))
- return false;
-
- if (pEntry->GetFlags() & SvTLEntryFlags::DISABLE_DROP)
- return false;
-
- return true;
+ return DND_ACTION_NONE;
}
-void SdPageObjsTLB::AddShapeToTransferable (
+void SdPageObjsTLV::AddShapeToTransferable (
SdTransferable& rTransferable,
SdrObject& rObject) const
{
@@ -1284,16 +568,14 @@ void SdPageObjsTLB::AddShapeToTransferable (
}
}
- ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
+ ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
if (bIsDescriptorFillingPending && pDocShell!=nullptr)
{
pDocShell->FillTransferableObjectDescriptor(*pObjectDescriptor);
}
Point aDragPos (rObject.GetCurrentBoundRect().Center());
- //Point aDragPos (0,0);
pObjectDescriptor->maDragStartPos = aDragPos;
- // aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
if (pDocShell != nullptr)
pObjectDescriptor->maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
else
@@ -1303,7 +585,7 @@ void SdPageObjsTLB::AddShapeToTransferable (
rTransferable.SetObjectDescriptor( std::move(pObjectDescriptor) );
}
-::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
+::sd::ViewShell* SdPageObjsTLV::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
{
{
::sd::ViewShell* pViewShell = rDocShell.GetViewShell();
@@ -1353,33 +635,57 @@ void SdPageObjsTLB::AddShapeToTransferable (
return nullptr;
}
-//===== IconProvider ==========================================================
-
-SdPageObjsTLB::IconProvider::IconProvider()
- : maImgPage(StockImage::Yes, BMP_PAGE),
- maImgPageExcl(StockImage::Yes, BMP_PAGE_EXCLUDED),
- maImgPageObjsExcl(StockImage::Yes, BMP_PAGEOBJS_EXCLUDED),
- maImgPageObjs(StockImage::Yes, BMP_PAGEOBJS),
- maImgObjects(StockImage::Yes, BMP_OBJECTS),
- maImgGroup(StockImage::Yes, BMP_GROUP)
-{
-}
-
SdPageObjsTLV::SdPageObjsTLV(std::unique_ptr<weld::TreeView> xTreeView)
: m_xTreeView(std::move(xTreeView))
+ , m_xDropTargetHelper(new SdPageObjsTLVDropTarget(*m_xTreeView))
, m_xAccel(::svt::AcceleratorExecute::createAcceleratorHelper())
, m_pDoc(nullptr)
, m_pBookmarkDoc(nullptr)
, m_pMedium(nullptr)
+ , m_pOwnMedium(nullptr)
, m_bLinkableSelected(false)
, m_bShowAllPages(false)
+ , m_bSelectionHandlerNavigates(false)
+ , m_bNavigationGrabsFocus(true)
+ , m_eSelectionMode(SelectionMode::Single)
+ , m_nSelectEventId(nullptr)
+ , m_nRowActivateEventId(nullptr)
{
m_xTreeView->connect_expanding(LINK(this, SdPageObjsTLV, RequestingChildrenHdl));
m_xTreeView->connect_changed(LINK(this, SdPageObjsTLV, SelectHdl));
+ m_xTreeView->connect_row_activated(LINK(this, SdPageObjsTLV, RowActivatedHdl));
+ m_xTreeView->connect_drag_begin(LINK(this, SdPageObjsTLV, DragBeginHdl));
+ m_xTreeView->connect_key_press(LINK(this, SdPageObjsTLV, KeyInputHdl));
+ m_xTreeView->connect_mouse_press(LINK(this, SdPageObjsTLV, MousePressHdl));
+ m_xTreeView->connect_mouse_release(LINK(this, SdPageObjsTLV, MouseReleaseHdl));
}
IMPL_LINK_NOARG(SdPageObjsTLV, SelectHdl, weld::TreeView&, void)
{
+ if (m_nSelectEventId)
+ Application::RemoveUserEvent(m_nSelectEventId);
+ // post the event to process select event after mouse press event
+ m_nSelectEventId = Application::PostUserEvent(LINK(this, SdPageObjsTLV, AsyncSelectHdl));
+}
+
+IMPL_LINK_NOARG(SdPageObjsTLV, RowActivatedHdl, weld::TreeView&, bool)
+{
+ if (m_nRowActivateEventId)
+ Application::RemoveUserEvent(m_nRowActivateEventId);
+ // post the event to process row activate after mouse press event
+ m_nRowActivateEventId = Application::PostUserEvent(LINK(this, SdPageObjsTLV, AsyncRowActivatedHdl));
+ return true;
+}
+
+IMPL_LINK_NOARG(SdPageObjsTLV, AsyncSelectHdl, void*, void)
+{
+ Select();
+}
+
+void SdPageObjsTLV::Select()
+{
+ m_nSelectEventId = nullptr;
+
m_bLinkableSelected = true;
m_xTreeView->selected_foreach([this](weld::TreeIter& rEntry){
@@ -1389,19 +695,68 @@ IMPL_LINK_NOARG(SdPageObjsTLV, SelectHdl, weld::TreeView&, void)
});
m_aChangeHdl.Call(*m_xTreeView);
+
+ if (m_bSelectionHandlerNavigates)
+ m_aRowActivatedHdl.Call(*m_xTreeView);
+
+ if (!m_xNavigator)
+ {
+ m_xHelper.clear();
+ return;
+ }
+
+ ::sd::DrawDocShell* pDocShell = m_pDoc->GetDocSh();
+ OUString aURL = INetURLObject(pDocShell->GetMedium()->GetPhysicalName(), INetProtocol::File).GetMainURL(INetURLObject::DecodeMechanism::NONE);
+ NavigatorDragType eDragType = m_xNavigator->GetNavigatorDragType();
+
+ OUString sSelectedEntry = m_xTreeView->get_selected_text();
+ aURL += "#" + sSelectedEntry;
+
+ INetBookmark aBookmark(aURL, sSelectedEntry);
+ sal_Int8 nDNDActions = DND_ACTION_COPYMOVE;
+
+ if( eDragType == NAVIGATOR_DRAGTYPE_LINK )
+ nDNDActions = DND_ACTION_LINK; // Either COPY *or* LINK, never both!
+ else if (m_pDoc->GetSdPageCount(PageKind::Standard) == 1)
+ {
+ // Can not move away the last slide in a document.
+ nDNDActions = DND_ACTION_COPY;
+ }
+
+ // object is destroyed by internal reference mechanism
+ m_xHelper.set(new SdPageObjsTLV::SdPageObjsTransferable(aBookmark, *pDocShell, eDragType));
+ rtl::Reference<TransferDataContainer> xHelper(m_xHelper.get());
+ m_xTreeView->enable_drag_source(xHelper, nDNDActions);
+}
+
+IMPL_LINK_NOARG(SdPageObjsTLV, AsyncRowActivatedHdl, void*, void)
+{
+ m_nRowActivateEventId = nullptr;
+ m_aRowActivatedHdl.Call(*m_xTreeView);
}
-OUString SdPageObjsTLV::GetObjectName(const SdrObject* pObject)
+OUString SdPageObjsTLV::GetObjectName(
+ const SdrObject* pObject,
+ const bool bCreate) const
{
- if ( !pObject )
- return OUString();
+ OUString aRet;
+
+ if ( pObject )
+ {
+ aRet = pObject->GetName();
- OUString aRet = pObject->GetName();
- if (!aRet.isEmpty())
- return aRet;
+ if (aRet.isEmpty() && dynamic_cast<const SdrOle2Obj* >(pObject) != nullptr)
+ aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName();
+ }
- if (auto pOle = dynamic_cast<const SdrOle2Obj* >(pObject))
- aRet = pOle->GetPersistName();
+ if (bCreate
+ && m_bShowAllShapes
+ && aRet.isEmpty()
+ && pObject!=nullptr)
+ {
+ aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME);
+ aRet = aRet.replaceFirst("%1", OUString::number(pObject->GetOrdNum() + 1));
+ }
return aRet;
}
@@ -1424,13 +779,42 @@ std::vector<OUString> SdPageObjsTLV::GetSelectEntryList(const int nDepth) const
* Checks if it is a draw file and opens the BookmarkDoc depending of
* the provided Docs
*/
-SdDrawDocument* SdPageObjsTLV::GetBookmarkDoc()
+SdDrawDocument* SdPageObjsTLV::GetBookmarkDoc(SfxMedium* pMed)
{
- if (!m_pBookmarkDoc)
+ if (
+ !m_pBookmarkDoc ||
+ (pMed && (!m_pOwnMedium || m_pOwnMedium->GetName() != pMed->GetName()))
+ )
{
- DBG_ASSERT( m_pMedium, "No SfxMedium provided!" );
+ // create a new BookmarkDoc if now one exists or if a new Medium is provided
+ if (m_pOwnMedium != pMed)
+ {
+ CloseBookmarkDoc();
+ }
+
+ if (pMed)
+ {
+ // it looks that it is undefined if a Medium was set by Fill() already
+ DBG_ASSERT( !m_pMedium, "SfxMedium confusion!" );
+ delete m_pMedium;
+ m_pMedium = nullptr;
+
+ // take over this Medium (currently used only be Navigator)
+ m_pOwnMedium = pMed;
+ }
- if ( m_pMedium )
+ DBG_ASSERT( m_pMedium || pMed, "No SfxMedium provided!" );
+
+ if( pMed )
+ {
+ // in this mode the document is also owned and controlled by this instance
+ m_xBookmarkDocShRef = new ::sd::DrawDocShell(SfxObjectCreateMode::STANDARD, true, DocumentType::Impress);
+ if (m_xBookmarkDocShRef->DoLoad(pMed))
+ m_pBookmarkDoc = m_xBookmarkDocShRef->GetDoc();
+ else
+ m_pBookmarkDoc = nullptr;
+ }
+ else if ( m_pMedium )
// in this mode the document is owned and controlled by the SdDrawDocument
// it can be released by calling the corresponding CloseBookmarkDoc method
// successful creation of a document makes this the owner of the medium
@@ -1526,6 +910,11 @@ IMPL_LINK(SdPageObjsTLV, RequestingChildrenHdl, const weld::TreeIter&, rFileEntr
return true;
}
+void SdPageObjsTLV::SetSdNavigator(SdNavigatorWin* pNavigator)
+{
+ m_xNavigator = pNavigator;
+}
+
void SdPageObjsTLV::SetViewFrame(const SfxViewFrame* pViewFrame)
{
sd::ViewShellBase* pBase = sd::ViewShellBase::GetViewShellBase(pViewFrame);
@@ -1542,9 +931,13 @@ void SdPageObjsTLV::CloseBookmarkDoc()
{
m_xBookmarkDocShRef->DoClose();
m_xBookmarkDocShRef.clear();
+
+ // Medium is owned by document, so it's destroyed already
+ m_pOwnMedium = nullptr;
}
else if (m_pBookmarkDoc)
{
+ DBG_ASSERT(!m_pOwnMedium, "SfxMedium confusion!");
if (m_pDoc)
{
// The document owns the Medium, so the Medium will be invalid after closing the document
@@ -1552,6 +945,12 @@ void SdPageObjsTLV::CloseBookmarkDoc()
m_pMedium = nullptr;
}
}
+ else
+ {
+ // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc
+ delete m_pOwnMedium;
+ m_pOwnMedium = nullptr;
+ }
m_pBookmarkDoc = nullptr;
}
@@ -1660,14 +1059,14 @@ void SdPageObjsTLV::AddShapeList (
/**
* Fill TreeLB with pages and objects
*/
-void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, const OUString& rDocName)
+void SdPageObjsTLV::Fill(const SdDrawDocument* pInDoc, bool bAllPages, const OUString& rDocName)
{
OUString aSelection = m_xTreeView->get_selected_text();
clear();
m_pDoc = pInDoc;
m_aDocName = rDocName;
- m_bShowAllPages = true;
+ m_bShowAllPages = bAllPages;
m_pMedium = nullptr;
// first insert all pages including objects
@@ -1760,6 +1159,11 @@ bool SdPageObjsTLV::SelectEntry( const OUString& rName )
SdPageObjsTLV::~SdPageObjsTLV()
{
+ if (m_nSelectEventId)
+ Application::RemoveUserEvent(m_nSelectEventId);
+ if (m_nRowActivateEventId)
+ Application::RemoveUserEvent(m_nRowActivateEventId);
+
if (m_pBookmarkDoc)
CloseBookmarkDoc();
else
diff --git a/sd/source/ui/dlg/tpaction.cxx b/sd/source/ui/dlg/tpaction.cxx
index 4eadc2a50279..5d75a1fa93bc 100644
--- a/sd/source/ui/dlg/tpaction.cxx
+++ b/sd/source/ui/dlg/tpaction.cxx
@@ -350,7 +350,7 @@ void SdTPAction::UpdateTree()
{
if( !bTreeUpdated && mpDoc && mpDoc->GetDocSh() && mpDoc->GetDocSh()->GetMedium() )
{
- m_xLbTree->Fill( mpDoc, mpDoc->GetDocSh()->GetMedium()->GetName() );
+ m_xLbTree->Fill( mpDoc, true, mpDoc->GetDocSh()->GetMedium()->GetName() );
bTreeUpdated = true;
}
}
@@ -645,7 +645,7 @@ IMPL_LINK_NOARG(SdTPAction, CheckFileHdl, weld::Widget&, void)
aLastFile = aFile;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list