1*9ee13d13SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9ee13d13SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9ee13d13SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9ee13d13SAndrew Rist  * distributed with this work for additional information
6*9ee13d13SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9ee13d13SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9ee13d13SAndrew Rist  * "License"); you may not use this file except in compliance
9*9ee13d13SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9ee13d13SAndrew Rist  *
11*9ee13d13SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9ee13d13SAndrew Rist  *
13*9ee13d13SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9ee13d13SAndrew Rist  * software distributed under the License is distributed on an
15*9ee13d13SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9ee13d13SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9ee13d13SAndrew Rist  * specific language governing permissions and limitations
18*9ee13d13SAndrew Rist  * under the License.
19*9ee13d13SAndrew Rist  *
20*9ee13d13SAndrew Rist  *************************************************************/
21*9ee13d13SAndrew Rist 
22*9ee13d13SAndrew Rist 
23cdf0e10cSrcweir #ifndef RPTUI_UITOOLS_HXX
24cdf0e10cSrcweir #define RPTUI_UITOOLS_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/report/XGroup.hpp>
27cdf0e10cSrcweir #include <com/sun/star/report/XReportControlFormat.hpp>
28cdf0e10cSrcweir #include <com/sun/star/report/XShape.hpp>
29cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
31cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp>
33cdf0e10cSrcweir #include "ReportSection.hxx"
34cdf0e10cSrcweir #include <rtl/ref.hxx>
35cdf0e10cSrcweir #include <vcl/taskpanelist.hxx>
36cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
37cdf0e10cSrcweir #include <functional>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir class SdrPage;
40cdf0e10cSrcweir class SdrObject;
41cdf0e10cSrcweir class SdrUnoObj;
42cdf0e10cSrcweir class SdrView;
43cdf0e10cSrcweir class Rectangle;
44cdf0e10cSrcweir namespace comphelper
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     class OPropertyChangeMultiplexer;
47cdf0e10cSrcweir     class OPropertyChangeListener;
48cdf0e10cSrcweir }
49cdf0e10cSrcweir namespace rptui
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	/** returns the position of the object inside the index container
52cdf0e10cSrcweir 		@param	_xReportDefinition	the report definition to get the groups
53cdf0e10cSrcweir 		@param	_xGroup	the group to search
54cdf0e10cSrcweir         @return returns the position of the group in the list, otherwise -1
55cdf0e10cSrcweir 	*/
getPositionInIndexAccess(const::com::sun::star::uno::Reference<::com::sun::star::container::XIndexAccess> & _xCollection,const::com::sun::star::uno::Reference<T> & _xSearch)56cdf0e10cSrcweir 	template<typename T> sal_Int32 getPositionInIndexAccess(
57cdf0e10cSrcweir                                 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _xCollection
58cdf0e10cSrcweir 								,const ::com::sun::star::uno::Reference< T >& _xSearch)
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir         sal_Int32 nCount = _xCollection->getCount();
61cdf0e10cSrcweir         sal_Int32 i = (nCount == 0) ? -1 : 0;
62cdf0e10cSrcweir 	    for (;i<nCount ; ++i)
63cdf0e10cSrcweir 	    {
64cdf0e10cSrcweir 		    ::com::sun::star::uno::Reference< T > xObject(_xCollection->getByIndex(i),::com::sun::star::uno::UNO_QUERY);
65cdf0e10cSrcweir 		    if ( xObject == _xSearch )
66cdf0e10cSrcweir 			    break;
67cdf0e10cSrcweir 	    } // for (;i<nCount ; ++i)
68cdf0e10cSrcweir 	    return i;
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	/** set the name of the header and footer of the group by the expression appended by the localized name of the section
72cdf0e10cSrcweir 		@param	_xGroup	the group where the header/footer name is set by the expression of the group
73cdf0e10cSrcweir 	*/
74cdf0e10cSrcweir 	void adjustSectionName(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroup >& _xGroup,sal_Int32 _nPos);
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /** add a listener for the properties size, left margin, right margin to the page style
77cdf0e10cSrcweir     *
78cdf0e10cSrcweir     * \param _xReportDefinition
79cdf0e10cSrcweir     * \param _pListener
80cdf0e10cSrcweir     * \return
81cdf0e10cSrcweir     */
82cdf0e10cSrcweir     ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportDefinition >& _xReportDefinition
83cdf0e10cSrcweir                                                                 ,::comphelper::OPropertyChangeListener* _pListener);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     /** opens the common character font dialog
86cdf0e10cSrcweir 	*/
87cdf0e10cSrcweir 	bool    openCharDialog(
88cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat>& _xReportControlFormat,
89cdf0e10cSrcweir 			    const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& _xWindow,
90cdf0e10cSrcweir                 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _out_rNewValues
91cdf0e10cSrcweir             );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     /** opens the area dialog for shapes
94cdf0e10cSrcweir     */
95cdf0e10cSrcweir     bool openAreaDialog(
96cdf0e10cSrcweir              const ::com::sun::star::uno::Reference< ::com::sun::star::report::XShape >& _xShape
97cdf0e10cSrcweir             ,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& _xWindow
98cdf0e10cSrcweir             );
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     /** opens the formula dialog
101cdf0e10cSrcweir         @param _out_rFormula
102cdf0e10cSrcweir                 the formula chosen by the user
103cdf0e10cSrcweir         @precond
104cdf0e10cSrcweir             we're really inspecting a database report (well, a RowSet at least)
105cdf0e10cSrcweir         @return
106cdf0e10cSrcweir             <TRUE/> if and only if the user successfully chose a clause
107cdf0e10cSrcweir     */
108cdf0e10cSrcweir     bool openDialogFormula_nothrow( ::rtl::OUString& _in_out_rFormula
109cdf0e10cSrcweir                                , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext
110cdf0e10cSrcweir                                , const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& _xWindow
111cdf0e10cSrcweir                                , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet
112cdf0e10cSrcweir                                );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     /** applies the character settings previously obtained via openCharDialog
115cdf0e10cSrcweir     */
116cdf0e10cSrcweir     void    applyCharacterSettings(
117cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportControlFormat >& _rxReportControlFormat,
118cdf0e10cSrcweir                 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSettings
119cdf0e10cSrcweir             );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     /** notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search _pWindow.
122cdf0e10cSrcweir 		@param	_pWindow
123cdf0e10cSrcweir 			The window which is used to search for the SystemWindow.
124cdf0e10cSrcweir 		@param	_pToRegister
125cdf0e10cSrcweir 			The window which should be added or removed on the TaskPaneList.
126cdf0e10cSrcweir 		@param	_rMemFunc
127cdf0e10cSrcweir 			The member function which should be called at the SystemWindow when found.
128cdf0e10cSrcweir 			Possible values are:
129cdf0e10cSrcweir 			::comphelper::mem_fun(&TaskPaneList::AddWindow)
130cdf0e10cSrcweir 			::comphelper::mem_fun(&TaskPaneList::RemoveWindow)
131cdf0e10cSrcweir 	*/
132cdf0e10cSrcweir     void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc);
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     const sal_Int16 ISOVER_IGNORE_CUSTOMSHAPES = 1;
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     /** checks whether the given rectangle overlapps another OUnoObject object in that view.
138cdf0e10cSrcweir     *
139cdf0e10cSrcweir     * \param _rRect
140cdf0e10cSrcweir     * \param _rPage
141cdf0e10cSrcweir     * \param _bAllObjects  if <TRUE/> all objects are taken into account, otherwise only not marked ones
142cdf0e10cSrcweir     * \return the object which is overlapped, otherwise <NULL/>
143cdf0e10cSrcweir     */
144cdf0e10cSrcweir     SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects = false,SdrObject* _pIgnore = NULL, sal_Int16 _nIgnoreType=0);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects, SdrUnoObj* _pIgnoreList[], int _nIgnoreListLength);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     /** checks whether the given OUnoObject object rectangle overlapps another object in that view.
149cdf0e10cSrcweir     *
150cdf0e10cSrcweir     * \param _pObj
151cdf0e10cSrcweir     * \param _rPage
152cdf0e10cSrcweir     * \param _rView
153cdf0e10cSrcweir     * \param _bAllObjects  if <TRUE/> all objects are taken into account, otherwise only not marked ones
154cdf0e10cSrcweir     * \return the object which is overlapped, otherwise <NULL/>. If the given object is not of type OUnoObject <NULL/> will be returned.
155cdf0e10cSrcweir     */
156cdf0e10cSrcweir     SdrObject* isOver(SdrObject* _pObj,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects = false);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     /** retrieves the names of the parameters of the command which the given RowSet is bound to
159cdf0e10cSrcweir     */
160cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString >
161cdf0e10cSrcweir         getParameterNames( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     /** ensures that no control overlaps the given one.
164cdf0e10cSrcweir     *
165cdf0e10cSrcweir     * \param pControl           the control which should place in the section without overlapping
166cdf0e10cSrcweir     * \param _pReportSection    the section
167cdf0e10cSrcweir     * \param _bInsert           sal_True whe the control should be inserted, otherwise not.
168cdf0e10cSrcweir     */
169cdf0e10cSrcweir     void correctOverlapping(SdrObject* pControl,OReportSection& _aReportSection,bool _bInsert = true);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     /** returns a Rectangle of a given SdrObject
172cdf0e10cSrcweir      *
173cdf0e10cSrcweir      * \param pControl          the SdrObject
174cdf0e10cSrcweir      */
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     Rectangle getRectangleFromControl(SdrObject* pControl);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     /** sets the map mode at the window
179cdf0e10cSrcweir         @param  _aZoom      the zoom scale
180cdf0e10cSrcweir         @param  _rWindow    where to set the map mode
181cdf0e10cSrcweir     */
182cdf0e10cSrcweir     void setZoomFactor(const Fraction& _aZoom,Window& _rWindow);
183cdf0e10cSrcweir }
184cdf0e10cSrcweir #endif //RPTUI_UITOOLS_HXX
185cdf0e10cSrcweir 
186