1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <svtools/transfer.hxx>
25 #include "sdresid.hxx"
28 #include <tools/string.hxx>
29 #include <svtools/treelistbox.hxx>
30 #include <svl/urlbmk.hxx>
31 #include <tools/ref.hxx>
33 #include <boost/scoped_ptr.hpp>
34 #include <boost/function.hpp>
43 class SvTreeListEntry
;
49 #ifndef SV_DECL_DRAW_DOC_SHELL_DEFINED
50 #define SV_DECL_DRAW_DOC_SHELL_DEFINED
51 SV_DECL_REF(DrawDocShell
)
58 class SD_DLLPUBLIC SdPageObjsTLB
: public SvTreeListBox
62 static sal_Bool SAL_DLLPRIVATE bIsInDrag
; ///< static, in the case the navigator is deleted in ExecuteDrag
66 // nested class to implement the TransferableHelper
67 class SdPageObjsTransferable
: public SdTransferable
70 SdPageObjsTransferable(
71 SdPageObjsTLB
& rParent
,
72 const INetBookmark
& rBookmark
,
73 ::sd::DrawDocShell
& rDocShell
,
74 NavigatorDragType eDragType
,
75 const ::com::sun::star::uno::Any
& rTreeListBoxData
);
76 ::sd::DrawDocShell
& GetDocShell() const;
77 NavigatorDragType
GetDragType() const;
79 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& getUnoTunnelId();
80 static SdPageObjsTransferable
* getImplementation( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxData
) throw();
81 /** Return a temporary transferable data flavor that is used
82 internally in the navigator for reordering entries. Its
83 lifetime ends with the office application.
85 static sal_uInt32
GetListBoxDropFormatId (void);
88 /** Temporary drop flavor id that is used internally in the
91 static sal_uInt32 mnListBoxDropFormatId
;
93 SdPageObjsTLB
& mrParent
;
94 INetBookmark maBookmark
;
95 ::sd::DrawDocShell
& mrDocShell
;
96 NavigatorDragType meDragType
;
97 const ::com::sun::star::uno::Any maTreeListBoxData
;
98 SAL_DLLPRIVATE
virtual ~SdPageObjsTransferable();
100 SAL_DLLPRIVATE
virtual void AddSupportedFormats();
101 SAL_DLLPRIVATE
virtual sal_Bool
GetData( const ::com::sun::star::datatransfer::DataFlavor
& rFlavor
);
102 SAL_DLLPRIVATE
virtual void DragFinished( sal_Int8 nDropAction
);
104 SAL_DLLPRIVATE
virtual sal_Int64 SAL_CALL
getSomething( const ::com::sun::star::uno::Sequence
< sal_Int8
>& rId
) throw( ::com::sun::star::uno::RuntimeException
);
107 friend class SdPageObjsTLB::SdPageObjsTransferable
;
109 /** Determine whether the specified page belongs to the current show
110 which is either the standard show or a custom show.
112 Pointer to the page for which to check whether it belongs to the
115 Returns <FALSE/> if there is no custom show or if the current
116 show does not contain the specified page at least once.
118 bool PageBelongsToCurrentShow (const SdPage
* pPage
) const;
123 const SdDrawDocument
* mpDoc
;
124 SdDrawDocument
* mpBookmarkDoc
;
126 SfxMedium
* mpOwnMedium
;
129 sal_Bool mbLinkableSelected
;
130 sal_Bool mbDragEnabled
;
132 ::sd::DrawDocShellRef mxBookmarkDocShRef
; ///< for the loading of bookmarks
133 ::sd::DrawDocShell
* mpDropDocSh
;
134 SdNavigatorWin
* mpDropNavWin
;
135 SfxViewFrame
* mpFrame
;
138 virtual void StartDrag( sal_Int8 nAction
, const Point
& rPosPixel
);
141 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
142 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
144 virtual void RequestingChildren( SvTreeListEntry
* pParent
);
147 void OnDragFinished( sal_uInt8 nDropAction
);
149 /** Return the name of the object. When the object has no user supplied
150 name and the bCreate flag is <TRUE/> then a name is created
151 automatically. Additionally the mbShowAllShapes flag is taken into
152 account when there is no user supplied name. When this flag is
153 <FALSE/> then no name is created.
155 When this is NULL then an empty string is returned, regardless
156 of the value of bCreate.
158 This flag controls for objects without user supplied name
159 whether a name is created. When a name is created then this
160 name is not stored in the object.
162 String
GetObjectName (
163 const SdrObject
* pObject
,
164 const bool bCreate
= true) const;
165 void CloseBookmarkDoc();
166 DECL_STATIC_LINK(SdPageObjsTLB
, ExecDragHdl
, void*);
168 /** Handle the reordering of entries in the navigator. This method
169 reorders both the involved shapes in their page as well as the
170 associated list box entries.
172 virtual sal_Bool
NotifyMoving(
173 SvTreeListEntry
* pTarget
,
174 SvTreeListEntry
* pEntry
,
175 SvTreeListEntry
*& rpNewParent
,
176 sal_uLong
& rNewChildPos
);
178 using Window::GetDropTarget
;
179 virtual SvTreeListEntry
* GetDropTarget (const Point
& rLocation
);
183 SdPageObjsTLB( Window
* pParent
, const SdResId
& rSdResId
);
186 virtual void SelectHdl();
187 virtual void KeyInput( const KeyEvent
& rKEvt
);
189 void SetViewFrame( SfxViewFrame
* pViewFrame
) { mpFrame
= pViewFrame
; }
190 SfxViewFrame
* GetViewFrame() const { return mpFrame
; }
192 void Fill( const SdDrawDocument
*, sal_Bool bAllPages
, const String
& rDocName
);
193 void Fill( const SdDrawDocument
*, SfxMedium
* pSfxMedium
, const String
& rDocName
);
194 void SetShowAllShapes (const bool bShowAllShapes
, const bool bFill
);
195 bool GetShowAllShapes (void) const;
196 sal_Bool
IsEqualToDoc( const SdDrawDocument
* pInDoc
= NULL
);
197 sal_Bool
HasSelectedChildren( const String
& rName
);
198 sal_Bool
SelectEntry( const String
& rName
);
199 String
GetSelectEntry();
201 /** return selected entries
203 nDepth == 1 -> objects */
205 std::vector
<OUString
> GetSelectEntryList (const sal_uInt16 nDepth
) const;
207 SdDrawDocument
* GetBookmarkDoc(SfxMedium
* pMedium
= NULL
);
208 ::sd::DrawDocShell
* GetDropDocSh() { return(mpDropDocSh
); }
210 sal_Bool
IsLinkableSelected() const { return mbLinkableSelected
; }
212 static sal_Bool
IsInDrag();
213 using SvTreeListBox::ExecuteDrop
;
215 using SvTreeListBox::SelectEntry
;
217 /** Return the view shell that is linked to the given doc shell.
218 Call this method when the there is a chance that the doc shell
219 has been disconnected from the view shell (but not the other
222 May return <NULL/> when the link between view shell and
223 doc shell has been severed.
225 static ::sd::ViewShell
* GetViewShellForDocShell (::sd::DrawDocShell
&rDocShell
);
228 /** This flag controls whether all shapes are shown as children of pages
229 and group shapes or only the named shapes.
231 bool mbShowAllShapes
;
232 /** This flag controls whether to show all pages.
236 /** Return <TRUE/> when the current transferable may be dropped at the
237 given list box entry.
239 bool IsDropAllowed (SvTreeListEntry
* pEntry
);
241 /** This inner class is defined in sdtreelb.cxx and is basically a
242 container for the icons used in the list box for the entries.
246 /** Add one list box entry for the parent of the given shapes and one child entry for
247 each of the given shapes.
249 The container of shapes that are to be inserted.
251 The parent shape or NULL when the parent is a page.
253 The name to be displayed for the new parent node.
255 Some pages can be excluded (from the show?).
257 The parent entry of the new parent entry.
259 Icons used to visualize the different shape and page types.
262 const SdrObjList
& rList
,
264 const OUString
& rsName
,
265 const bool bIsExcluded
,
266 SvTreeListEntry
* pParentEntry
,
267 const IconProvider
& rIconProvider
);
269 /** Add the given object to a transferable object so that the object can
270 be dragged and dropped without having a name.
272 void AddShapeToTransferable (
273 SdTransferable
& rTransferable
,
274 SdrObject
& rObject
) const;
277 #endif // _SDTREELB_HXX
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */