1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVX_GALBRWS2_HXX_ 25 #define _SVX_GALBRWS2_HXX_ 26 27 #include <vcl/lstbox.hxx> 28 #include <vcl/button.hxx> 29 #include <vcl/fixed.hxx> 30 #include <vcl/timer.hxx> 31 #include <vcl/toolbox.hxx> 32 #include <svtools/transfer.hxx> 33 #include <svl/lstner.hxx> 34 #include <svtools/miscopt.hxx> 35 #include "svx/galbrws.hxx" 36 37 #include <com/sun/star/frame/XDispatch.hpp> 38 #include <com/sun/star/util/XURLTransformer.hpp> 39 40 // ---------------------- 41 // - GalleryBrowserMode - 42 // ---------------------- 43 44 enum GalleryBrowserMode 45 { 46 GALLERYBROWSERMODE_NONE = 0, 47 GALLERYBROWSERMODE_ICON = 1, 48 GALLERYBROWSERMODE_LIST = 2, 49 GALLERYBROWSERMODE_PREVIEW = 3 50 }; 51 52 // ----------------- 53 // - GalleryTravel - 54 // ----------------- 55 56 enum GalleryBrowserTravel 57 { 58 GALLERYBROWSERTRAVEL_CURRENT = 0, 59 GALLERYBROWSERTRAVEL_FIRST = 1, 60 GALLERYBROWSERTRAVEL_LAST = 2, 61 GALLERYBROWSERTRAVEL_PREVIOUS = 3, 62 GALLERYBROWSERTRAVEL_NEXT = 4 63 }; 64 65 // ------------------------ 66 // - GalleryItemTextFlags - 67 // ------------------------ 68 69 #define GALLERY_ITEM_THEMENAME 0x00000001 70 #define GALLERY_ITEM_TITLE 0x00000002 71 #define GALLERY_ITEM_PATH 0x00000004 72 73 // ------------------ 74 // - GalleryToolBox - 75 // ------------------ 76 77 class GalleryToolBox : public ToolBox 78 { 79 private: 80 81 virtual void KeyInput( const KeyEvent& rKEvt ); 82 83 public: 84 85 GalleryToolBox( GalleryBrowser2* pParent ); 86 ~GalleryToolBox(); 87 }; 88 89 // ------------------- 90 // - GalleryBrowser2 - 91 // ------------------- 92 93 class Gallery; 94 class GalleryTheme; 95 class GalleryIconView; 96 class GalleryListView; 97 class GalleryPreview; 98 class Menu; 99 class SgaObject; 100 struct DispatchInfo; 101 102 namespace svx { namespace sidebar { class GalleryControl; } } 103 104 class GalleryBrowser2 : public Control, public SfxListener 105 { 106 friend class GalleryBrowser; 107 friend class svx::sidebar::GalleryControl; 108 using Control::Notify; 109 using Window::KeyInput; 110 111 private: 112 113 SvtMiscOptions maMiscOptions; 114 Gallery* mpGallery; 115 GalleryTheme* mpCurTheme; 116 GalleryIconView* mpIconView; 117 GalleryListView* mpListView; 118 GalleryPreview* mpPreview; 119 GalleryToolBox maViewBox; 120 FixedLine maSeparator; 121 FixedText maInfoBar; 122 Point maDragStartPos; 123 sal_uIntPtr mnCurActionPos; 124 GalleryBrowserMode meMode; 125 GalleryBrowserMode meLastMode; 126 127 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext; 128 com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > m_xTransformer; 129 130 void InitSettings(); 131 132 void ImplUpdateViews( sal_uInt16 nSelectionId ); 133 void ImplUpdateInfoBar(); 134 sal_uIntPtr ImplGetSelectedItemId( const Point* pSelPosPixel, Point& rSelPos ); 135 void ImplSelectItemId( sal_uIntPtr nItemId ); 136 137 // Control 138 virtual void Resize(); 139 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 140 141 // SfxListener 142 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 143 144 DECL_LINK( SelectObjectHdl, void* ); 145 DECL_LINK( SelectTbxHdl, ToolBox* ); 146 DECL_LINK( MiscHdl, void* ); 147 148 private: 149 150 static GalleryBrowserMode meInitMode; 151 152 public: 153 154 static String GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, sal_uIntPtr nItemTextFlags ); 155 156 public: 157 158 GalleryBrowser2( Window* pParent, const ResId& rResId, Gallery* pGallery ); 159 ~GalleryBrowser2(); 160 161 void SelectTheme( const String& rThemeName ); 162 GetMode() const163 GalleryBrowserMode GetMode() const { return meMode; } 164 void SetMode( GalleryBrowserMode eMode ); 165 166 Window* GetViewWindow() const; 167 168 void Travel( GalleryBrowserTravel eTravel ); 169 170 INetURLObject GetURL() const; 171 String GetFilterName() const; 172 Graphic GetGraphic() const; 173 sal_Bool GetVCDrawModel( FmFormModel& rModel ) const; 174 175 sal_Int8 AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& rEvt ); 176 sal_Int8 ExecuteDrop( DropTargetHelper& rTarget, const ExecuteDropEvent& rEvt ); 177 void StartDrag( Window* pWindow, const Point* pDragPoint = NULL ); 178 void TogglePreview( Window* pWindow, const Point* pPreviewPoint = NULL ); 179 void ShowContextMenu( Window* pWindow, const Point* pContextPoint = NULL ); 180 sal_Bool KeyInput( const KeyEvent& rEvt, Window* pWindow ); 181 182 com::sun::star::uno::Reference< com::sun::star::frame::XFrame > GetFrame() const; GetUNOContext() const183 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > GetUNOContext() const { return m_xContext; } GetURLTransformer() const184 com::sun::star::uno::Reference< com::sun::star::util::XURLTransformer > GetURLTransformer() const { return m_xTransformer; } 185 186 void Execute( sal_uInt16 nId ); 187 void Dispatch( sal_uInt16 nId, 188 const com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > &rxDispatch = com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >(), 189 const com::sun::star::util::URL &rURL = com::sun::star::util::URL() ); 190 191 DECL_STATIC_LINK( GalleryBrowser2, AsyncDispatch_Impl, DispatchInfo* ); 192 }; 193 194 #endif 195