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 SD_SLIDESORTER_PAGE_OBJECT_VIEW_OBJECT_CONTACT_HXX 25 #define SD_SLIDESORTER_PAGE_OBJECT_VIEW_OBJECT_CONTACT_HXX 26 27 #include <svx/sdr/contact/viewobjectcontactofpageobj.hxx> 28 #include "model/SlsSharedPageDescriptor.hxx" 29 #include <svx/sdr/contact/viewobjectcontact.hxx> 30 #include <vcl/bitmapex.hxx> 31 #include <vcl/image.hxx> 32 #include <sfx2/viewfrm.hxx> 33 #include <memory> 34 #include <boost/shared_ptr.hpp> 35 36 class SdrPage; 37 38 namespace sdr { namespace contact { 39 class DisplayInfo; 40 } } 41 42 namespace sd { namespace slidesorter { namespace cache { 43 class PageCache; 44 } } } 45 46 namespace sd { namespace slidesorter { namespace controller { 47 class Properties; 48 } } } 49 50 namespace sd { namespace slidesorter { namespace view { 51 52 class SlideSorterView; 53 54 /** This object-view-contact of page objects maintains a preview bitmap for 55 the page to speed up redraws of the same. It does so by collaborating 56 with a cache of bitmaps (see ../cache). 57 */ 58 59 // needs to be derived from ViewObjectContactOfPageObj, else the calls to parent implementations 60 // would use ViewObjectContact and thus not enable e.g. the correct primitive creation 61 // for view-independent printer output 62 // changed: ViewObjectContact -> ViewObjectContactOfPageObj 63 64 class PageObjectViewObjectContact : public ::sdr::contact::ViewObjectContactOfPageObj 65 { 66 public: 67 /** Create a new view-object-contact object for the given contact 68 objects of both model and view. 69 @param pCache 70 The caller should provide a pointer to a preview cache, if 71 available. If given then the cache is used to control when to 72 create a preview and to store it. If NULL is given then the 73 preview is created every time when requested. 74 */ 75 PageObjectViewObjectContact ( 76 ::sdr::contact::ObjectContact& rObjectContact, 77 ::sdr::contact::ViewContact& rViewContact, 78 const ::boost::shared_ptr<cache::PageCache>& rpCache, 79 const ::boost::shared_ptr<controller::Properties>& rpProperties); 80 virtual ~PageObjectViewObjectContact (void); 81 82 /** This method is primarily for releasing the current preview cache (by 83 providing a NULL pointer.) 84 */ 85 void SetCache (const ::boost::shared_ptr<cache::PageCache>& rpCache); 86 87 /** Return the page that is painted by this object. 88 */ 89 const SdrPage* GetPage (void) const; 90 91 /** This fallback method is called when no preview cache is available. 92 It creates a preview for the page. 93 */ 94 BitmapEx CreatePreview (const sdr::contact::DisplayInfo& rDisplayInfo); 95 96 /** Return the page descriptor of the slide sorter model that is 97 associated with the same page object as this contact object is. 98 */ 99 model::SharedPageDescriptor GetPageDescriptor (void) const; 100 101 /** Return the border widths in the screen coordinate system of the 102 border around the page object. The border contains frames for 103 selection, focus, the page name and number, and the indicator for 104 the page transition. 105 @param pDevice 106 The output device is used to convert pixel coordinates into 107 model coordinates. When NULL is given then the device dependent 108 part is not re-calculated but taken from an earlier calculation 109 or from the default values. 110 @param nPageCount 111 The total number of pages is used to determine the width of the 112 box that contains the page number. 113 */ 114 static SvBorder CalculatePageModelBorder ( 115 OutputDevice* pDevice, 116 int nPageCount); 117 118 /** Calculate the size of the page number area so that all page numbers 119 including the given number fit in. Because this is device dependent 120 we need the device as parameter. The result is returned and stored 121 in maPageNumberAreaPixelSize so that it can be used later without 122 access to the device or page count. 123 */ 124 static Size CalculatePageNumberAreaModelSize ( 125 OutputDevice* pDevice, 126 int nPageCount); 127 128 /** Paint a mouse over effect. 129 @param bVisible 130 When bVisible is <FALSE/> then paint the area of the mouse over 131 effect in the background color, i.e. erase it. 132 */ 133 drawinglayer::primitive2d::Primitive2DSequence createMouseOverEffectPrimitive2DSequence(); 134 135 enum BoundingBoxType { 136 // This is the outer bounding box that includes the preview, page 137 // number, title. 138 PageObjectBoundingBox, 139 // Bounding box of the actual preview. 140 PreviewBoundingBox, 141 // Bounding box of the mouse indicator indicator frame. 142 MouseOverIndicatorBoundingBox, 143 // Bounding box of the focus indicator frame. 144 FocusIndicatorBoundingBox, 145 // Bounding box of the selection indicator frame. 146 SelectionIndicatorBoundingBox, 147 // Bounding box of the page number. 148 PageNumberBoundingBox, 149 // Bounding box of the pane name. 150 NameBoundingBox, 151 FadeEffectIndicatorBoundingBox 152 }; 153 enum CoordinateSystem { ModelCoordinateSystem, PixelCoordinateSystem }; 154 155 /** Return the bounding box of the page object or one of its graphical 156 parts. 157 @param rDevice 158 This device is used to translate between model and window 159 coordinates. 160 @param eType 161 The part of the page object for which to return the bounding 162 box. 163 @param eCoodinateSystem 164 The bounding box can be returned in model and in pixel 165 (window) coordinates. 166 */ 167 Rectangle GetBoundingBox ( 168 OutputDevice& rDevice, 169 BoundingBoxType eType, 170 CoordinateSystem eCoordinateSystem) const; 171 172 // create the graphical visualization data 173 virtual drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequence(const sdr::contact::DisplayInfo& rDisplayInfo) const; 174 175 // access to the current page content primitive vector which may be used for visualization getCurrentPageContents() const176 const drawinglayer::primitive2d::Primitive2DSequence& getCurrentPageContents() const { return mxCurrentPageContents; } 177 178 virtual void ActionChanged (void); 179 180 private: 181 /// Gap between border of page object and inside of selection rectangle. 182 static const sal_Int32 mnSelectionIndicatorOffset; 183 /// Thickness of the selection rectangle. 184 static const sal_Int32 mnSelectionIndicatorThickness; 185 /// Gap between border of page object and inside of focus rectangle. 186 static const sal_Int32 mnFocusIndicatorOffset; 187 /// Size of width and height of the fade effect indicator in pixels. 188 static const sal_Int32 mnFadeEffectIndicatorSize; 189 static const sal_Int32 mnFadeEffectIndicatorOffset; 190 /// Gap between border of page object and number rectangle. 191 static const sal_Int32 mnPageNumberOffset; 192 /// Offset and thickness of the mouse over effect rectangle. 193 static const sal_Int32 mnMouseOverEffectOffset; 194 static const sal_Int32 mnMouseOverEffectThickness; 195 196 /** This flag is set to <TRUE/> when the destructor is called to 197 indicate that further calls made to it must not call outside. 198 */ 199 bool mbInDestructor; 200 201 /// The primitive sequence of the page contents, completely scaled 202 /// and prepared for painting 203 drawinglayer::primitive2d::Primitive2DSequence mxCurrentPageContents; 204 205 ::boost::shared_ptr<cache::PageCache> mpCache; 206 207 ::boost::shared_ptr<controller::Properties> mpProperties; 208 209 BitmapEx GetPreview ( 210 const sdr::contact::DisplayInfo& rDisplayInfo, 211 const Rectangle& rNewSizePixel); 212 213 /** Return the bounding box of where the page number is painted (when it 214 is painted). 215 */ 216 Rectangle GetPageNumberArea (OutputDevice& rDevice) const; 217 }; 218 219 } } } // end of namespace ::sd::slidesorter::view 220 221 #endif 222