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 #ifndef RPTUI_SCROLLHELPER_HXX 24 #define RPTUI_SCROLLHELPER_HXX 25 26 #include <vcl/scrbar.hxx> 27 #include <com/sun/star/report/XSection.hpp> 28 #include <comphelper/propmultiplex.hxx> 29 #include "ReportDefines.hxx" 30 #include <svtools/colorcfg.hxx> 31 #include <svx/svdedtv.hxx> 32 #include "cppuhelper/basemutex.hxx" 33 #include <rtl/ref.hxx> 34 #include <boost/shared_ptr.hpp> 35 #include <vcl/dockwin.hxx> 36 #include <MarkedSection.hxx> 37 #include "ReportWindow.hxx" 38 39 class SdrView; 40 namespace rptui 41 { 42 class ODesignView; 43 class OReportWindow; 44 class OSectionView; 45 class OReportSection; 46 class OReportModel; 47 48 /** This class defines the scrollable area of the report design. It includes 49 the h-ruler and the sections, and end marker. Not the start marker. 50 */ 51 typedef Window OScrollWindowHelper_BASE; 52 class OScrollWindowHelper : public ::cppu::BaseMutex 53 , public OScrollWindowHelper_BASE/*TabPage*/ 54 , public ::comphelper::OPropertyChangeListener 55 , public IMarkedSection 56 { 57 private: 58 ScrollBar m_aHScroll; 59 ScrollBar m_aVScroll; 60 ScrollBarBox m_aCornerWin; // window in the bottom right corner 61 Size m_aTotalPixelSize; 62 ODesignView* m_pParent; 63 OReportWindow m_aReportWindow; 64 ::rtl::Reference<comphelper::OPropertyChangeMultiplexer > 65 m_pReportDefintionMultiPlexer; // listener for property changes 66 67 DECL_LINK( ScrollHdl, ScrollBar*); 68 Size ResizeScrollBars(); 69 void ImplInitSettings(); 70 void impl_initScrollBar( ScrollBar& _rScrollBar ) const; 71 72 OScrollWindowHelper(OScrollWindowHelper&); 73 void operator =(OScrollWindowHelper&); 74 protected: 75 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 76 // window 77 virtual void Resize(); 78 virtual long Notify( NotifyEvent& rNEvt ); 79 // OPropertyChangeListener 80 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException); 81 public: 82 OScrollWindowHelper( ODesignView* _pReportDesignView); 83 virtual ~OScrollWindowHelper(); 84 85 /** late ctor 86 */ 87 void initialize(); 88 getThumbPos() const89 inline Point getThumbPos() const { return Point(m_aHScroll.GetThumbPos(),m_aVScroll.GetThumbPos())/*m_aScrollOffset*/; } getReportWindow() const90 inline const OReportWindow& getReportWindow() const { return m_aReportWindow; } 91 void setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight); getTotalSize() const92 inline Size getTotalSize() const { return m_aTotalPixelSize; } GetHScroll()93 inline ScrollBar* GetHScroll() { return &m_aHScroll; } GetVScroll()94 inline ScrollBar* GetVScroll() { return &m_aVScroll; } 95 96 // forwards 97 void SetMode( DlgEdMode _eMode ); 98 void SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType = ::rtl::OUString()); 99 rtl::OUString GetInsertObjString() const; 100 void setGridSnap(sal_Bool bOn); 101 void setDragStripes(sal_Bool bOn); 102 /** copies the current selection in this section 103 */ 104 void Copy(); 105 106 /** returns if paste is allowed 107 * 108 * \return <TRUE/> if paste is allowed 109 */ 110 sal_Bool IsPasteAllowed() const; 111 112 /** paste a new control in this section 113 */ 114 void Paste(); 115 116 /** Deletes the current selection in this section 117 * 118 */ 119 void Delete(); 120 121 /** All objects will be marked. 122 */ 123 void SelectAll(const sal_uInt16 _nObjectType); 124 125 /** returns <TRUE/> when a object is marked 126 */ 127 sal_Bool HasSelection() const; 128 129 /** removes the section at the given position. 130 * 131 * \param _nPosition Zero based. 132 */ 133 void removeSection(sal_uInt16 _nPosition); 134 135 /** adds a new section at position _nPosition. 136 If the section is <NULL/> nothing happens. 137 If the position is grater than the current elements, the section will be appended. 138 */ 139 void addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection 140 ,const ::rtl::OUString& _sColorEntry 141 ,sal_uInt16 _nPosition = USHRT_MAX); 142 143 sal_uInt16 getSectionCount() const; 144 145 /** turns the grid on or off 146 * 147 * \param _bVisible 148 */ 149 void toggleGrid(sal_Bool _bVisible); 150 151 /** unmark all objects on the views without the given one. 152 * 153 * @param _pSectionView The view where the objects should not be unmarked. 154 */ 155 void unmarkAllObjects(OSectionView* _pSectionView); 156 157 /** shows or hides the ruler. 158 */ 159 void showRuler(sal_Bool _bShow); 160 161 /** calculate the max width of the markers 162 * 163 * @param _bWithEnd if <TRUE/> the end marker will be used for calculation as well otherwise not. 164 * \return the max width 165 */ 166 sal_Int32 getMaxMarkerWidth(sal_Bool _bWithEnd) const; 167 168 /** checks if the keycode is known by the child windows 169 @param _rCode the keycode 170 @return <TRUE/> if the keycode is handled otherwise <FALSE/> 171 */ 172 sal_Bool handleKeyEvent(const KeyEvent& _rEvent); 173 174 /** the the section as marked or not marked 175 @param _pSectionView the section where to set the marked flag 176 @param _bMark the marked flag 177 */ 178 void setMarked(OSectionView* _pSectionView,sal_Bool _bMark); 179 void setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark); 180 void setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark); 181 182 // IMarkedSection 183 ::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const; 184 ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const; 185 virtual void markSection(const sal_uInt16 _nPos); 186 187 188 /** fills the positions of all collapsed sections. 189 * 190 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections. 191 */ 192 void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const; 193 194 /** collpase all sections given by their position 195 * 196 * \param _aCollpasedSections The position of the sections which should be collapsed. 197 */ 198 void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections); 199 200 /** align all marked objects in all sections 201 * 202 * \param eHor 203 * \param eVert 204 * \param bBoundRects 205 */ 206 void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false); 207 208 sal_uInt32 getMarkedObjectCount() const; 209 210 /** zoom the ruler and view windows 211 */ 212 void zoom(const Fraction& _aZoom); 213 214 /** fills the vector with all selected control models 215 /param _rSelection The vector will be filled and will not be cleared before. 216 */ 217 void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const; 218 219 /** calculates the zoom factor. 220 @param _eType which kind of zoom is needed 221 */ 222 sal_uInt16 getZoomFactor(SvxZoomType _eType) const; 223 }; 224 } 225 #endif // RPTUI_SCROLLHELPER_HXX 226