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