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