1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9e0e4191SAndrew Rist  * distributed with this work for additional information
6*9e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9e0e4191SAndrew Rist  *
11*9e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9e0e4191SAndrew Rist  *
13*9e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist  * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9e0e4191SAndrew Rist  * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist  * under the License.
19*9e0e4191SAndrew Rist  *
20*9e0e4191SAndrew Rist  *************************************************************/
21*9e0e4191SAndrew Rist 
22*9e0e4191SAndrew Rist 
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #define RPTUI_ID_LRSPACE	1
26cdf0e10cSrcweir #define RPTUI_ID_ULSPACE	2
27cdf0e10cSrcweir #define RPTUI_ID_PAGE		3
28cdf0e10cSrcweir #define RPTUI_ID_SIZE		4
29cdf0e10cSrcweir #define RPTUI_ID_PAGE_MODE	5
30cdf0e10cSrcweir #define RPTUI_ID_START		6
31cdf0e10cSrcweir #define RPTUI_ID_END		7
32cdf0e10cSrcweir #define RPTUI_ID_BRUSH		8
33cdf0e10cSrcweir #define RPTUI_ID_METRIC		9
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #define ITEMID_LRSPACE      RPTUI_ID_LRSPACE
36cdf0e10cSrcweir #define ITEMID_ULSPACE      RPTUI_ID_ULSPACE
37cdf0e10cSrcweir #define ITEMID_SIZE         RPTUI_ID_SIZE
38cdf0e10cSrcweir #define ITEMID_PAGE			RPTUI_ID_PAGE
39cdf0e10cSrcweir #define ITEMID_BRUSH		RPTUI_ID_BRUSH
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include "ReportController.hxx"
43cdf0e10cSrcweir #include "ReportDefinition.hxx"
44cdf0e10cSrcweir #include "CondFormat.hxx"
45cdf0e10cSrcweir #include "UITools.hxx"
46cdf0e10cSrcweir #include "AddField.hxx"
47cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
48cdf0e10cSrcweir #include "DateTime.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
51cdf0e10cSrcweir #include <tools/string.hxx>
52cdf0e10cSrcweir #include <tools/diagnose_ex.h>
53cdf0e10cSrcweir #include "rptui_slotid.hrc"
54cdf0e10cSrcweir #include "reportformula.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <comphelper/documentconstants.hxx>
57cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
58cdf0e10cSrcweir #include <comphelper/property.hxx>
59cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
60cdf0e10cSrcweir #include <comphelper/types.hxx>
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
63cdf0e10cSrcweir #include <com/sun/star/view/PaperFormat.hpp>
64cdf0e10cSrcweir #include <com/sun/star/style/GraphicLocation.hpp>
65cdf0e10cSrcweir #include <com/sun/star/style/XStyle.hpp>
66cdf0e10cSrcweir #include <com/sun/star/style/PageStyleLayout.hpp>
67cdf0e10cSrcweir #include <com/sun/star/style/ParagraphAdjust.hpp>
68cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
69cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
70cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
71cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
72cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
73cdf0e10cSrcweir #include <com/sun/star/datatransfer/XTransferable.hpp>
74cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
75cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
76cdf0e10cSrcweir #include <com/sun/star/report/XImageControl.hpp>
77cdf0e10cSrcweir #include <com/sun/star/report/XFixedLine.hpp>
78cdf0e10cSrcweir #include <com/sun/star/report/Function.hpp>
79cdf0e10cSrcweir #include <com/sun/star/report/XShape.hpp>
80cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
81cdf0e10cSrcweir #include <com/sun/star/sdb/XDocumentDataSource.hpp>
82cdf0e10cSrcweir #include <com/sun/star/sdb/XParametersSupplier.hpp>
83cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp>
84cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
85cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
86cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
87cdf0e10cSrcweir #include <com/sun/star/embed/EmbedMapUnits.hpp>
88cdf0e10cSrcweir #include <comphelper/streamsection.hxx>
89cdf0e10cSrcweir #include <com/sun/star/awt/FontWeight.hpp>
90cdf0e10cSrcweir #include <com/sun/star/awt/FontUnderline.hpp>
91cdf0e10cSrcweir #include <com/sun/star/awt/TextAlign.hpp>
92cdf0e10cSrcweir #include <com/sun/star/awt/FontSlant.hpp>
93cdf0e10cSrcweir #include <com/sun/star/frame/status/FontHeight.hpp>
94cdf0e10cSrcweir #include <com/sun/star/report/XFormattedField.hpp>
95cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp>
96cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
97cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
98cdf0e10cSrcweir #include <com/sun/star/document/XUndoManagerSupplier.hpp>
99cdf0e10cSrcweir 
100cdf0e10cSrcweir #include <vcl/svapp.hxx>
101cdf0e10cSrcweir #include <vcl/msgbox.hxx>
102cdf0e10cSrcweir #include <vcl/waitobj.hxx>
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #include <svx/fmview.hxx>
105cdf0e10cSrcweir #include <editeng/paperinf.hxx>
106cdf0e10cSrcweir #include <editeng/memberids.hrc>
107cdf0e10cSrcweir #include <svx/svxids.hrc>
108cdf0e10cSrcweir #include <svx/svdobj.hxx>
109cdf0e10cSrcweir #include <svx/dataaccessdescriptor.hxx>
110cdf0e10cSrcweir #include <editeng/svxenum.hxx>
111cdf0e10cSrcweir #include <svx/pageitem.hxx>
112cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
113cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
114cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
115cdf0e10cSrcweir #include <svx/zoomitem.hxx>
116cdf0e10cSrcweir #include <svx/zoomslideritem.hxx>
117cdf0e10cSrcweir #include <editeng/brshitem.hxx>
118cdf0e10cSrcweir #include <svx/flagsdef.hxx>
119cdf0e10cSrcweir #include <svx/svdpagv.hxx>
120cdf0e10cSrcweir #include <svx/svxdlg.hxx>
121cdf0e10cSrcweir #include <svx/zoom_def.hxx>
122cdf0e10cSrcweir #include <svx/dialogs.hrc>
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #include "DesignView.hxx"
125cdf0e10cSrcweir #include "ModuleHelper.hxx"
126cdf0e10cSrcweir #include "RptObject.hxx"
127cdf0e10cSrcweir #include "RptUndo.hxx"
128cdf0e10cSrcweir #include "uistrings.hrc"
129cdf0e10cSrcweir #include "RptDef.hxx"
130cdf0e10cSrcweir #include "ReportSection.hxx"
131cdf0e10cSrcweir #include "SectionView.hxx"
132cdf0e10cSrcweir #include "UndoActions.hxx"
133cdf0e10cSrcweir #include "dlgpage.hxx"
134cdf0e10cSrcweir #include "RptResId.hrc"
135cdf0e10cSrcweir 
136cdf0e10cSrcweir #include <svl/itempool.hxx>
137cdf0e10cSrcweir #include <svl/itemset.hxx>
138cdf0e10cSrcweir #include <svl/aeitem.hxx>
139cdf0e10cSrcweir #include <svtools/cliplistener.hxx>
140cdf0e10cSrcweir #include <unotools/syslocale.hxx>
141cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
142cdf0e10cSrcweir 
143cdf0e10cSrcweir #include <vos/mutex.hxx>
144cdf0e10cSrcweir #include "PropertyForward.hxx"
145cdf0e10cSrcweir #include "SectionWindow.hxx"
146cdf0e10cSrcweir 
147cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
148cdf0e10cSrcweir #include "GroupsSorting.hxx"
149cdf0e10cSrcweir #include "PageNumber.hxx"
150cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
151cdf0e10cSrcweir #include "UndoEnv.hxx"
152cdf0e10cSrcweir #include "InsertFunctions.hxx"
153cdf0e10cSrcweir #include "ReportControllerObserver.hxx"
154cdf0e10cSrcweir 
155cdf0e10cSrcweir #include <boost/mem_fn.hpp>
156cdf0e10cSrcweir #include <boost/bind.hpp>
157cdf0e10cSrcweir #include <boost/utility.hpp>
158cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
161cdf0e10cSrcweir #include <unotools/confignode.hxx>
162cdf0e10cSrcweir #include <helpids.hrc>
163cdf0e10cSrcweir 
164cdf0e10cSrcweir #include <ReportControllerObserver.hxx>
165cdf0e10cSrcweir 
166cdf0e10cSrcweir #define MAX_ROWS_FOR_PREVIEW    20
167cdf0e10cSrcweir 
168cdf0e10cSrcweir using namespace ::com::sun::star;
169cdf0e10cSrcweir using namespace uno;
170cdf0e10cSrcweir using namespace io;
171cdf0e10cSrcweir using namespace beans;
172cdf0e10cSrcweir using namespace frame;
173cdf0e10cSrcweir using namespace util;
174cdf0e10cSrcweir using namespace lang;
175cdf0e10cSrcweir using namespace container;
176cdf0e10cSrcweir using namespace sdbcx;
177cdf0e10cSrcweir using namespace sdbc;
178cdf0e10cSrcweir using namespace sdb;
179cdf0e10cSrcweir using namespace ui;
180cdf0e10cSrcweir using namespace ui::dialogs;
181cdf0e10cSrcweir using namespace util;
182cdf0e10cSrcweir using namespace ::dbtools;
183cdf0e10cSrcweir using namespace ::rptui;
184cdf0e10cSrcweir using namespace ::dbaui;
185cdf0e10cSrcweir using namespace ::comphelper;
186cdf0e10cSrcweir using namespace ::cppu;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir // -----------------------------------------------------------------------------
189cdf0e10cSrcweir namespace
190cdf0e10cSrcweir {
191cdf0e10cSrcweir     // comparing two PropertyValue instances
192cdf0e10cSrcweir     struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, ::rtl::OUString , bool >
193cdf0e10cSrcweir     {
operator ()__anonf61fcd140111::PropertyValueCompare194cdf0e10cSrcweir 	    bool operator() (const beans::PropertyValue& x, const ::rtl::OUString& y) const
195cdf0e10cSrcweir 	    {
196cdf0e10cSrcweir 		    return x.Name.equals(y);// ? true : false;
197cdf0e10cSrcweir 	    }
operator ()__anonf61fcd140111::PropertyValueCompare198cdf0e10cSrcweir         bool operator() (const ::rtl::OUString& x,const beans::PropertyValue& y) const
199cdf0e10cSrcweir 	    {
200cdf0e10cSrcweir 		    return x.equals(y.Name);// ? true : false;
201cdf0e10cSrcweir 	    }
202cdf0e10cSrcweir     };
203cdf0e10cSrcweir 
lcl_setFontWPU_nothrow(const uno::Reference<report::XReportControlFormat> & _xReportControlFormat,const sal_Int32 _nId)204cdf0e10cSrcweir     void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId)
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         if ( _xReportControlFormat.is() )
207cdf0e10cSrcweir 	    {
208cdf0e10cSrcweir 		    try
209cdf0e10cSrcweir 		    {
210cdf0e10cSrcweir 			    awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
211cdf0e10cSrcweir                 switch(_nId)
212cdf0e10cSrcweir                 {
213cdf0e10cSrcweir                     case SID_ATTR_CHAR_WEIGHT:
214cdf0e10cSrcweir                         aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight;
215cdf0e10cSrcweir                         break;
216cdf0e10cSrcweir                     case SID_ATTR_CHAR_POSTURE:
217cdf0e10cSrcweir                         aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant));
218cdf0e10cSrcweir                         break;
219cdf0e10cSrcweir                     case SID_ATTR_CHAR_UNDERLINE:
220cdf0e10cSrcweir                         aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline;
221cdf0e10cSrcweir                         break;
222cdf0e10cSrcweir                     default:
223cdf0e10cSrcweir                         OSL_ENSURE(0,"Illegal value in default!");
224cdf0e10cSrcweir                         break;
225cdf0e10cSrcweir                 }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 			    _xReportControlFormat->setFontDescriptor(aFontDescriptor);
228cdf0e10cSrcweir 		    }
229cdf0e10cSrcweir 		    catch(beans::UnknownPropertyException&)
230cdf0e10cSrcweir 		    {
231cdf0e10cSrcweir 		    }
232cdf0e10cSrcweir 	    } // if ( xReportControlFormat.is() )
233cdf0e10cSrcweir     }
234cdf0e10cSrcweir }
235cdf0e10cSrcweir 
236cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getReportControlFormat(const Sequence<PropertyValue> & aArgs,ODesignView * _pView,uno::Reference<awt::XWindow> & _xWindow,::std::vector<uno::Reference<uno::XInterface>> & _rControlsFormats)237cdf0e10cSrcweir void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,
238cdf0e10cSrcweir                                  ODesignView* _pView,
239cdf0e10cSrcweir                                  uno::Reference< awt::XWindow>& _xWindow,
240cdf0e10cSrcweir                                  ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir 	uno::Reference< report::XReportControlFormat> xReportControlFormat;
243cdf0e10cSrcweir 	if ( aArgs.getLength() )
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		SequenceAsHashMap aMap(aArgs);
246cdf0e10cSrcweir 		xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>());
247cdf0e10cSrcweir 		_xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>());
248cdf0e10cSrcweir 	}
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	if ( !xReportControlFormat.is() )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         _pView->fillControlModelSelection(_rControlsFormats);
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir     else
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir         _rControlsFormats.push_back(xReportControlFormat);
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	if ( !_xWindow.is() )
260cdf0e10cSrcweir 		_xWindow = VCLUnoHelper::GetInterface(_pView);
261cdf0e10cSrcweir }
262cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementationName()263cdf0e10cSrcweir ::rtl::OUString SAL_CALL OReportController::getImplementationName() throw( RuntimeException )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	return getImplementationName_Static();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir //------------------------------------------------------------------------------
getImplementationName_Static()269cdf0e10cSrcweir ::rtl::OUString OReportController::getImplementationName_Static() throw( RuntimeException )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.ReportDesign"));
272cdf0e10cSrcweir }
273cdf0e10cSrcweir //------------------------------------------------------------------------------
getSupportedServiceNames_Static(void)274cdf0e10cSrcweir Sequence< ::rtl::OUString> OReportController::getSupportedServiceNames_Static(void) throw( RuntimeException )
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	Sequence< ::rtl::OUString> aSupported(1);
277cdf0e10cSrcweir 	aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ReportDesign"));
278cdf0e10cSrcweir 	return aSupported;
279cdf0e10cSrcweir }
280cdf0e10cSrcweir //-------------------------------------------------------------------------
getSupportedServiceNames()281cdf0e10cSrcweir Sequence< ::rtl::OUString> SAL_CALL OReportController::getSupportedServiceNames() throw(RuntimeException)
282cdf0e10cSrcweir {
283cdf0e10cSrcweir 	return getSupportedServiceNames_Static();
284cdf0e10cSrcweir }
285cdf0e10cSrcweir // -------------------------------------------------------------------------
create(Reference<XComponentContext> const & xContext)286cdf0e10cSrcweir Reference< XInterface > OReportController::create(Reference< XComponentContext > const & xContext)
287cdf0e10cSrcweir {
288cdf0e10cSrcweir 	return *(new OReportController(xContext));
289cdf0e10cSrcweir }
290cdf0e10cSrcweir 
291cdf0e10cSrcweir #define PROPERTY_ID_ZOOMVALUE   1
292cdf0e10cSrcweir 
DBG_NAME(rpt_OReportController)293cdf0e10cSrcweir DBG_NAME( rpt_OReportController )
294cdf0e10cSrcweir // -----------------------------------------------------------------------------
295cdf0e10cSrcweir OReportController::OReportController(Reference< XComponentContext > const & xContext)
296cdf0e10cSrcweir     :OReportController_BASE(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))
297cdf0e10cSrcweir     ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper)
298cdf0e10cSrcweir     ,m_aSelectionListeners( getMutex() )
299cdf0e10cSrcweir     ,m_pClipbordNotifier(NULL)
300cdf0e10cSrcweir     ,m_pGroupsFloater(NULL)
301cdf0e10cSrcweir     ,m_xContext(xContext)
302cdf0e10cSrcweir     ,m_nSplitPos(-1)
303cdf0e10cSrcweir     ,m_nPageNum(-1)
304cdf0e10cSrcweir     ,m_nSelectionCount(0)
305cdf0e10cSrcweir     ,m_nZoomValue(100)
306cdf0e10cSrcweir     ,m_eZoomType(SVX_ZOOM_PERCENT)
307cdf0e10cSrcweir     ,m_bShowRuler(sal_True)
308cdf0e10cSrcweir     ,m_bGridVisible(sal_True)
309cdf0e10cSrcweir     ,m_bGridUse(sal_True)
310cdf0e10cSrcweir     ,m_bShowProperties(sal_True)
311cdf0e10cSrcweir     ,m_bGroupFloaterWasVisible(sal_False)
312cdf0e10cSrcweir     ,m_bHelplinesMove(sal_True)
313cdf0e10cSrcweir     ,m_bChartEnabled(false)
314cdf0e10cSrcweir     ,m_bChartEnabledAsked(false)
315cdf0e10cSrcweir     ,m_bInGeneratePreview(false)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     // new Observer
318cdf0e10cSrcweir     m_pReportControllerObserver = new OXReportControllerObserver(*this);
319cdf0e10cSrcweir     m_pReportControllerObserver->acquire();
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	m_sMode =  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal"));
322cdf0e10cSrcweir     DBG_CTOR( rpt_OReportController,NULL);
323cdf0e10cSrcweir     registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomValue")),PROPERTY_ID_ZOOMVALUE,beans::PropertyAttribute::BOUND| beans::PropertyAttribute::TRANSIENT,&m_nZoomValue,::getCppuType(reinterpret_cast< sal_Int16*>(NULL)));
324cdf0e10cSrcweir 
325cdf0e10cSrcweir }
326cdf0e10cSrcweir // -----------------------------------------------------------------------------
~OReportController()327cdf0e10cSrcweir OReportController::~OReportController()
328cdf0e10cSrcweir {
329cdf0e10cSrcweir     DBG_DTOR( rpt_OReportController,NULL);
330cdf0e10cSrcweir }
331cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)332cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)
333cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener)
334cdf0e10cSrcweir // -----------------------------------------------------------------------------
335cdf0e10cSrcweir void OReportController::disposing()
336cdf0e10cSrcweir {
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	if ( m_pClipbordNotifier )
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		m_pClipbordNotifier->ClearCallbackLink();
341cdf0e10cSrcweir 		m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
342cdf0e10cSrcweir 		m_pClipbordNotifier->release();
343cdf0e10cSrcweir 		m_pClipbordNotifier = NULL;
344cdf0e10cSrcweir 	} // if ( getView() && m_pClipbordNotifier )
345cdf0e10cSrcweir     if ( m_pGroupsFloater )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) );
348cdf0e10cSrcweir         aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pGroupsFloater->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) );
349cdf0e10cSrcweir 		::std::auto_ptr<FloatingWindow> aTemp(m_pGroupsFloater);
350cdf0e10cSrcweir 		m_pGroupsFloater = NULL;
351cdf0e10cSrcweir 	}
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     try
354cdf0e10cSrcweir     {
355cdf0e10cSrcweir         m_xHoldAlive.clear();
356cdf0e10cSrcweir         m_xColumns.clear();
357cdf0e10cSrcweir         ::comphelper::disposeComponent( m_xRowSet );
358cdf0e10cSrcweir         ::comphelper::disposeComponent( m_xRowSetMediator );
359cdf0e10cSrcweir         ::comphelper::disposeComponent( m_xFormatter );
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir     catch(uno::Exception&)
362cdf0e10cSrcweir     {
363cdf0e10cSrcweir         OSL_ENSURE(0,"Exception caught while disposing row sets.");
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir     m_xRowSet.clear();
366cdf0e10cSrcweir     m_xRowSetMediator.clear();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     if ( m_xReportDefinition.is() )
369cdf0e10cSrcweir     {
370cdf0e10cSrcweir         try
371cdf0e10cSrcweir 	    {
372cdf0e10cSrcweir             ::boost::shared_ptr<OSectionWindow> pSectionWindow;
373cdf0e10cSrcweir             if ( getDesignView() )
374cdf0e10cSrcweir                 pSectionWindow = getDesignView()->getMarkedSection();
375cdf0e10cSrcweir             if ( pSectionWindow )
376cdf0e10cSrcweir                 pSectionWindow->getReportSection().deactivateOle();
377cdf0e10cSrcweir             clearUndoManager();
378cdf0e10cSrcweir             if ( m_aReportModel )
379cdf0e10cSrcweir                 listen(false);
380cdf0e10cSrcweir             m_pReportControllerObserver->Clear();
381cdf0e10cSrcweir             m_pReportControllerObserver->release();
382cdf0e10cSrcweir         }
383cdf0e10cSrcweir         catch ( const uno::Exception& )
384cdf0e10cSrcweir 	    {
385cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
386cdf0e10cSrcweir 	    }
387cdf0e10cSrcweir     }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     {
390cdf0e10cSrcweir         EventObject aDisposingEvent( *this );
391cdf0e10cSrcweir         m_aSelectionListeners.disposeAndClear( aDisposingEvent );
392cdf0e10cSrcweir     }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir     OReportController_BASE::disposing();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     try
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir         m_xReportDefinition.clear();
400cdf0e10cSrcweir         m_aReportModel.reset();
401cdf0e10cSrcweir         m_xFrameLoader.clear();
402cdf0e10cSrcweir         m_xReportEngine.clear();
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir     catch(uno::Exception&)
405cdf0e10cSrcweir 	{
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir     if ( getDesignView() )
408cdf0e10cSrcweir         EndListening( *getDesignView() );
409cdf0e10cSrcweir     clearView();
410cdf0e10cSrcweir }
411cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetState(sal_uInt16 _nId) const412cdf0e10cSrcweir FeatureState OReportController::GetState(sal_uInt16 _nId) const
413cdf0e10cSrcweir {
414cdf0e10cSrcweir 	FeatureState aReturn;
415cdf0e10cSrcweir 	// (disabled automatically)
416cdf0e10cSrcweir 	aReturn.bEnabled = sal_False;
417cdf0e10cSrcweir 	// check this first
418cdf0e10cSrcweir 	if ( !getView() )
419cdf0e10cSrcweir 		return aReturn;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	switch (_nId)
422cdf0e10cSrcweir 	{
423cdf0e10cSrcweir         case SID_RPT_TEXTDOCUMENT:
424cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
425cdf0e10cSrcweir             aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT);
426cdf0e10cSrcweir             break;
427cdf0e10cSrcweir         case SID_RPT_SPREADSHEET:
428cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
429cdf0e10cSrcweir             aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET);
430cdf0e10cSrcweir             break;
431cdf0e10cSrcweir 		case SID_REPORTHEADER_WITHOUT_UNDO:
432cdf0e10cSrcweir 		case SID_REPORTFOOTER_WITHOUT_UNDO:
433cdf0e10cSrcweir 		case SID_REPORTHEADERFOOTER:
434cdf0e10cSrcweir             {
435cdf0e10cSrcweir 			    aReturn.bEnabled = isEditable();
436cdf0e10cSrcweir                 ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT));
437cdf0e10cSrcweir                 aReturn.sTitle = sText;
438cdf0e10cSrcweir             }
439cdf0e10cSrcweir 			break;
440cdf0e10cSrcweir 		case SID_PAGEHEADER_WITHOUT_UNDO:
441cdf0e10cSrcweir 		case SID_PAGEFOOTER_WITHOUT_UNDO:
442cdf0e10cSrcweir 		case SID_PAGEHEADERFOOTER:
443cdf0e10cSrcweir             {
444cdf0e10cSrcweir 			    aReturn.bEnabled = isEditable();
445cdf0e10cSrcweir                 ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT));
446cdf0e10cSrcweir                 aReturn.sTitle = sText;
447cdf0e10cSrcweir             }
448cdf0e10cSrcweir 			break;
449cdf0e10cSrcweir 		case SID_GROUP_APPEND:
450cdf0e10cSrcweir 		case SID_GROUP_REMOVE:
451cdf0e10cSrcweir 		case SID_GROUPHEADER_WITHOUT_UNDO:
452cdf0e10cSrcweir 		case SID_GROUPHEADER:
453cdf0e10cSrcweir 		case SID_GROUPFOOTER_WITHOUT_UNDO:
454cdf0e10cSrcweir 		case SID_GROUPFOOTER:
455cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
456cdf0e10cSrcweir             break;
457cdf0e10cSrcweir 		case SID_ADD_CONTROL_PAIR:
458cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
459cdf0e10cSrcweir 			break;
460cdf0e10cSrcweir 		case SID_REDO:
461cdf0e10cSrcweir 		case SID_UNDO:
462cdf0e10cSrcweir             {
463cdf0e10cSrcweir                 size_t ( SfxUndoManager::*retrieveCount )( bool const ) const =
464cdf0e10cSrcweir                     ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount;
465cdf0e10cSrcweir 
466cdf0e10cSrcweir                 SfxUndoManager& rUndoManager( getUndoManager() );
467cdf0e10cSrcweir                 aReturn.bEnabled = ( rUndoManager.*retrieveCount )( ::svl::IUndoManager::TopLevel ) > 0;
468cdf0e10cSrcweir                 if ( aReturn.bEnabled )
469cdf0e10cSrcweir                 {
470cdf0e10cSrcweir                     // TODO: add "Undo/Redo: prefix"
471cdf0e10cSrcweir                     String ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const =
472cdf0e10cSrcweir                         ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment;
473cdf0e10cSrcweir                     aReturn.sTitle = (rUndoManager.*retrieveComment)( 0, ::svl::IUndoManager::TopLevel );
474cdf0e10cSrcweir                 }
475cdf0e10cSrcweir             }
476cdf0e10cSrcweir 			break;
477cdf0e10cSrcweir         case SID_OBJECT_RESIZING:
478cdf0e10cSrcweir         case SID_OBJECT_SMALLESTWIDTH:
479cdf0e10cSrcweir         case SID_OBJECT_SMALLESTHEIGHT:
480cdf0e10cSrcweir         case SID_OBJECT_GREATESTWIDTH:
481cdf0e10cSrcweir         case SID_OBJECT_GREATESTHEIGHT:
482cdf0e10cSrcweir             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();// && getDesignView()->isAlignPossible();
483cdf0e10cSrcweir             if ( aReturn.bEnabled )
484cdf0e10cSrcweir                 aReturn.bEnabled = m_nSelectionCount > 1;
485cdf0e10cSrcweir 			break;
486cdf0e10cSrcweir 
487cdf0e10cSrcweir         case SID_DISTRIBUTION:
488cdf0e10cSrcweir             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
489cdf0e10cSrcweir             if ( aReturn.bEnabled )
490cdf0e10cSrcweir             {
491cdf0e10cSrcweir                 OSectionView* pSectionView = getCurrentSectionView();
492cdf0e10cSrcweir                 aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2;
493cdf0e10cSrcweir             }
494cdf0e10cSrcweir             break;
495cdf0e10cSrcweir         case SID_ARRANGEMENU:
496cdf0e10cSrcweir         case SID_FRAME_DOWN:
497cdf0e10cSrcweir         case SID_FRAME_UP:
498cdf0e10cSrcweir         case SID_FRAME_TO_TOP:
499cdf0e10cSrcweir         case SID_FRAME_TO_BOTTOM:
500cdf0e10cSrcweir         case SID_OBJECT_HEAVEN:
501cdf0e10cSrcweir         case SID_OBJECT_HELL:
502cdf0e10cSrcweir             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
503cdf0e10cSrcweir             if ( aReturn.bEnabled )
504cdf0e10cSrcweir             {
505cdf0e10cSrcweir                 OSectionView* pSectionView = getCurrentSectionView();
506cdf0e10cSrcweir                 aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked();
507cdf0e10cSrcweir                 if ( aReturn.bEnabled )
508cdf0e10cSrcweir                 {
509cdf0e10cSrcweir                     if ( SID_OBJECT_HEAVEN == _nId )
510cdf0e10cSrcweir                         aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT;
511cdf0e10cSrcweir                     else if ( SID_OBJECT_HELL == _nId )
512cdf0e10cSrcweir                         aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK;
513cdf0e10cSrcweir                 }
514cdf0e10cSrcweir             }
515cdf0e10cSrcweir             break;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir         case SID_SECTION_SHRINK:
518cdf0e10cSrcweir         case SID_SECTION_SHRINK_TOP:
519cdf0e10cSrcweir         case SID_SECTION_SHRINK_BOTTOM:
520cdf0e10cSrcweir         	{
521cdf0e10cSrcweir                 sal_Int32 nCount = 0;
522cdf0e10cSrcweir                 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
523cdf0e10cSrcweir                 if ( xSection.is() )
524cdf0e10cSrcweir                 {
525cdf0e10cSrcweir                     nCount = xSection->getCount();
526cdf0e10cSrcweir                 }
527cdf0e10cSrcweir                 aReturn.bEnabled = isEditable() && nCount > 0;
528cdf0e10cSrcweir             }
529cdf0e10cSrcweir             break;
530cdf0e10cSrcweir         case SID_OBJECT_ALIGN:
531cdf0e10cSrcweir         case SID_OBJECT_ALIGN_LEFT:
532cdf0e10cSrcweir         case SID_OBJECT_ALIGN_CENTER:
533cdf0e10cSrcweir         case SID_OBJECT_ALIGN_RIGHT:
534cdf0e10cSrcweir         case SID_OBJECT_ALIGN_UP:
535cdf0e10cSrcweir         case SID_OBJECT_ALIGN_MIDDLE:
536cdf0e10cSrcweir         case SID_OBJECT_ALIGN_DOWN:
537cdf0e10cSrcweir         case SID_SECTION_ALIGN:
538cdf0e10cSrcweir         case SID_SECTION_ALIGN_LEFT:
539cdf0e10cSrcweir         case SID_SECTION_ALIGN_CENTER:
540cdf0e10cSrcweir         case SID_SECTION_ALIGN_RIGHT:
541cdf0e10cSrcweir         case SID_SECTION_ALIGN_UP:
542cdf0e10cSrcweir         case SID_SECTION_ALIGN_MIDDLE:
543cdf0e10cSrcweir         case SID_SECTION_ALIGN_DOWN:
544cdf0e10cSrcweir             aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();// && getDesignView()->isAlignPossible();
545cdf0e10cSrcweir 			break;
546cdf0e10cSrcweir 		case SID_CUT:
547cdf0e10cSrcweir 			aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
548cdf0e10cSrcweir 			break;
549cdf0e10cSrcweir 		case SID_COPY:
550cdf0e10cSrcweir 			aReturn.bEnabled = getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
551cdf0e10cSrcweir 			break;
552cdf0e10cSrcweir 		case SID_PASTE:
553cdf0e10cSrcweir 			aReturn.bEnabled = isEditable()  && !getDesignView()->isHandleEvent(_nId) && getDesignView()->IsPasteAllowed();
554cdf0e10cSrcweir 			break;
555cdf0e10cSrcweir 		case SID_SELECTALL:
556cdf0e10cSrcweir 			aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId);
557cdf0e10cSrcweir 			break;
558cdf0e10cSrcweir         case SID_SELECTALL_IN_SECTION:
559cdf0e10cSrcweir             aReturn.bEnabled = !getDesignView()->isHandleEvent(_nId);
560cdf0e10cSrcweir             if ( aReturn.bEnabled )
561cdf0e10cSrcweir                 aReturn.bEnabled = getCurrentSectionView() != NULL;
562cdf0e10cSrcweir 			break;
563cdf0e10cSrcweir         case SID_ESCAPE:
564cdf0e10cSrcweir             aReturn.bEnabled = getDesignView()->GetMode() == RPTUI_INSERT;
565cdf0e10cSrcweir             break;
566cdf0e10cSrcweir         case SID_TERMINATE_INPLACEACTIVATION:
567cdf0e10cSrcweir             aReturn.bEnabled = sal_True;
568cdf0e10cSrcweir             break;
569cdf0e10cSrcweir         case SID_SELECT_ALL_EDITS:
570cdf0e10cSrcweir         case SID_SELECT_ALL_LABELS:
571cdf0e10cSrcweir             aReturn.bEnabled = sal_True;
572cdf0e10cSrcweir             break;
573cdf0e10cSrcweir         case SID_RPT_NEW_FUNCTION:
574cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
575cdf0e10cSrcweir             break;
576cdf0e10cSrcweir         case SID_COLLAPSE_SECTION:
577cdf0e10cSrcweir         case SID_EXPAND_SECTION:
578cdf0e10cSrcweir         case SID_NEXT_MARK:
579cdf0e10cSrcweir         case SID_PREV_MARK:
580cdf0e10cSrcweir             aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent(_nId);
581cdf0e10cSrcweir             break;
582cdf0e10cSrcweir         case SID_SELECT:
583cdf0e10cSrcweir 		case SID_SELECT_REPORT:
584cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
585cdf0e10cSrcweir 			break;
586cdf0e10cSrcweir         case SID_EXECUTE_REPORT:
587cdf0e10cSrcweir             aReturn.bEnabled = isConnected() && m_xReportDefinition.is();
588cdf0e10cSrcweir             break;
589cdf0e10cSrcweir 		case SID_DELETE:
590cdf0e10cSrcweir 			aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent(_nId);
591cdf0e10cSrcweir             if ( aReturn.bEnabled )
592cdf0e10cSrcweir             {
593cdf0e10cSrcweir                 ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
594cdf0e10cSrcweir                 if ( pSectionWindow )
595cdf0e10cSrcweir                     aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive();
596cdf0e10cSrcweir             }
597cdf0e10cSrcweir             {
598cdf0e10cSrcweir                 ::rtl::OUString sText = String(ModuleRes(RID_STR_DELETE));
599cdf0e10cSrcweir                 aReturn.sTitle = sText;
600cdf0e10cSrcweir             }
601cdf0e10cSrcweir 			break;
602cdf0e10cSrcweir 		case SID_GRID_VISIBLE:
603cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
604cdf0e10cSrcweir 			aReturn.bChecked = m_bGridVisible;
605cdf0e10cSrcweir 			break;
606cdf0e10cSrcweir 		case SID_GRID_USE:
607cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
608cdf0e10cSrcweir 			aReturn.bChecked = m_bGridUse;
609cdf0e10cSrcweir 			break;
610cdf0e10cSrcweir         case SID_HELPLINES_MOVE:
611cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
612cdf0e10cSrcweir 			aReturn.bChecked = m_bHelplinesMove;
613cdf0e10cSrcweir             break;
614cdf0e10cSrcweir 		case SID_RULER:
615cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
616cdf0e10cSrcweir 			aReturn.bChecked = m_bShowRuler;
617cdf0e10cSrcweir 			break;
618cdf0e10cSrcweir 		case SID_OBJECT_SELECT:
619cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
620cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetMode() == RPTUI_SELECT;
621cdf0e10cSrcweir 			break;
622cdf0e10cSrcweir         case SID_INSERT_DIAGRAM:
623cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
624cdf0e10cSrcweir             aReturn.bInvisible = optional< bool >(!m_bChartEnabled);
625cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_OLE2;
626cdf0e10cSrcweir             break;
627cdf0e10cSrcweir 		case SID_FM_FIXEDTEXT:
628cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
629cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FIXEDTEXT;
630cdf0e10cSrcweir 			break;
631cdf0e10cSrcweir         case SID_INSERT_HFIXEDLINE:
632cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
633cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_HFIXEDLINE;
634cdf0e10cSrcweir 			break;
635cdf0e10cSrcweir         case SID_INSERT_VFIXEDLINE:
636cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
637cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_VFIXEDLINE;
638cdf0e10cSrcweir 			break;
639cdf0e10cSrcweir 		case SID_FM_EDIT:
640cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
641cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FORMATTEDFIELD;
642cdf0e10cSrcweir 			break;
643cdf0e10cSrcweir 		case SID_FM_IMAGECONTROL:
644cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
645cdf0e10cSrcweir 			aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_IMAGECONTROL;
646cdf0e10cSrcweir 			break;
647cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC:
648cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC1:
649cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC2:
650cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC3:
651cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC4:
652cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC5:
653cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC6:
654cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC7:
655cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC8:
656cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC9:
657cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC10:
658cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC11:
659cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC12:
660cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC13:
661cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC14:
662cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC15:
663cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC16:
664cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC17:
665cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC18:
666cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC19:
667cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC20:
668cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC21:
669cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC22:
670cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("diamond",aReturn);
671cdf0e10cSrcweir 	        break;
672cdf0e10cSrcweir         case SID_DRAWTBX_CS_SYMBOL:
673cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL1:
674cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL2:
675cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL3:
676cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL4:
677cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL5:
678cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL6:
679cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL7:
680cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL8:
681cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL9:
682cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL10:
683cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL11:
684cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL12:
685cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL13:
686cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL14:
687cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL15:
688cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL16:
689cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL17:
690cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL18:
691cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("smiley",aReturn);
692cdf0e10cSrcweir             break;
693cdf0e10cSrcweir         case SID_DRAWTBX_CS_ARROW:
694cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW1:
695cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW2:
696cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW3:
697cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW4:
698cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW5:
699cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW6:
700cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW7:
701cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW8:
702cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW9:
703cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW10:
704cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW11:
705cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW12:
706cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW13:
707cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW14:
708cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW15:
709cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW16:
710cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW17:
711cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW18:
712cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW19:
713cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW20:
714cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW21:
715cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW22:
716cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW23:
717cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW24:
718cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW25:
719cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW26:
720cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn);
721cdf0e10cSrcweir             break;
722cdf0e10cSrcweir         case SID_DRAWTBX_CS_STAR:
723cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR1:
724cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR2:
725cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR3:
726cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR4:
727cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR5:
728cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR6:
729cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR7:
730cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR8:
731cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR9:
732cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR10:
733cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR11:
734cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR12:
735cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("star5",aReturn);
736cdf0e10cSrcweir             break;
737cdf0e10cSrcweir         case SID_DRAWTBX_CS_FLOWCHART:
738cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART1:
739cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART2:
740cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART3:
741cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART4:
742cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART5:
743cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART6:
744cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART7:
745cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART8:
746cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART9:
747cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART10:
748cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART11:
749cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART12:
750cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART13:
751cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART14:
752cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART15:
753cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART16:
754cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART17:
755cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART18:
756cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART19:
757cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART20:
758cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART21:
759cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART22:
760cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART23:
761cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART24:
762cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART25:
763cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART26:
764cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART27:
765cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART28:
766cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn);
767cdf0e10cSrcweir             break;
768cdf0e10cSrcweir         case SID_DRAWTBX_CS_CALLOUT:
769cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT1:
770cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT2:
771cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT3:
772cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT4:
773cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT5:
774cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT6:
775cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT7:
776cdf0e10cSrcweir             impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn);
777cdf0e10cSrcweir             break;
778cdf0e10cSrcweir         case SID_RPT_SHOWREPORTEXPLORER:
779cdf0e10cSrcweir             aReturn.bEnabled = m_xReportDefinition.is();
780cdf0e10cSrcweir 			aReturn.bChecked = getDesignView() && getDesignView()->isReportExplorerVisible();
781cdf0e10cSrcweir             break;
782cdf0e10cSrcweir 		case SID_FM_ADD_FIELD:
783cdf0e10cSrcweir             aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is()
784cdf0e10cSrcweir                 && m_xReportDefinition->getCommand().getLength();
785cdf0e10cSrcweir 			aReturn.bChecked = getDesignView() && getDesignView()->isAddFieldVisible();
786cdf0e10cSrcweir 			break;
787cdf0e10cSrcweir 		case SID_SHOW_PROPERTYBROWSER:
788cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
789cdf0e10cSrcweir 			aReturn.bChecked = m_bShowProperties;
790cdf0e10cSrcweir 			break;
791cdf0e10cSrcweir         case SID_PROPERTYBROWSER_LAST_PAGE:
792cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
793cdf0e10cSrcweir             aReturn.aValue <<= m_sLastActivePage;
794cdf0e10cSrcweir             break;
795cdf0e10cSrcweir         case SID_SPLIT_POSITION:
796cdf0e10cSrcweir             aReturn.bEnabled = sal_True;
797cdf0e10cSrcweir             aReturn.aValue <<= getSplitPos();
798cdf0e10cSrcweir             break;
799cdf0e10cSrcweir 		case SID_SAVEDOC:
800cdf0e10cSrcweir 			aReturn.bEnabled = impl_isModified() && isEditable();
801cdf0e10cSrcweir 			break;
802cdf0e10cSrcweir 		case SID_SAVEASDOC:
803cdf0e10cSrcweir 			aReturn.bEnabled = isConnected() && isEditable();
804cdf0e10cSrcweir 			break;
805cdf0e10cSrcweir 		case SID_EDITDOC:
806cdf0e10cSrcweir 			aReturn.bChecked = isEditable();
807cdf0e10cSrcweir 			break;
808cdf0e10cSrcweir         case SID_PAGEDIALOG:
809cdf0e10cSrcweir 			aReturn.bEnabled = isEditable();
810cdf0e10cSrcweir 			break;
811cdf0e10cSrcweir 		case SID_BACKGROUND_COLOR:
812cdf0e10cSrcweir             impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn);
813cdf0e10cSrcweir 			break;
814cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR_BACKGROUND:
815cdf0e10cSrcweir             aReturn.bEnabled = isEditable();
816cdf0e10cSrcweir 			{
817cdf0e10cSrcweir 				uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
818cdf0e10cSrcweir 				if ( xSection.is() )
819cdf0e10cSrcweir 					try
820cdf0e10cSrcweir 					{
821cdf0e10cSrcweir 						aReturn.aValue <<= xSection->getBackColor();
822cdf0e10cSrcweir                         const uno::Reference< report::XReportControlModel> xControlModel(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
823cdf0e10cSrcweir 						aReturn.bEnabled = !xControlModel.is();
824cdf0e10cSrcweir 					}
825cdf0e10cSrcweir 					catch(beans::UnknownPropertyException&)
826cdf0e10cSrcweir 					{
827cdf0e10cSrcweir 					}
828cdf0e10cSrcweir 				else
829cdf0e10cSrcweir 					aReturn.bEnabled = sal_False;
830cdf0e10cSrcweir 			}
831cdf0e10cSrcweir 			break;
832cdf0e10cSrcweir 		case SID_SORTINGANDGROUPING:
833cdf0e10cSrcweir 			aReturn.bEnabled = sal_True;
834cdf0e10cSrcweir 			aReturn.bChecked = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
835cdf0e10cSrcweir 			break;
836cdf0e10cSrcweir 		case SID_ATTR_CHAR_WEIGHT:
837cdf0e10cSrcweir 		case SID_ATTR_CHAR_POSTURE:
838cdf0e10cSrcweir 		case SID_ATTR_CHAR_UNDERLINE:
839cdf0e10cSrcweir 			impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
840cdf0e10cSrcweir             if ( aReturn.bEnabled )
841cdf0e10cSrcweir             {
842cdf0e10cSrcweir                 awt::FontDescriptor aFontDescriptor;
843cdf0e10cSrcweir                 aReturn.aValue >>= aFontDescriptor;
844cdf0e10cSrcweir                 aReturn.aValue.clear();
845cdf0e10cSrcweir 
846cdf0e10cSrcweir 			    switch(_nId)
847cdf0e10cSrcweir 			    {
848cdf0e10cSrcweir 				    case SID_ATTR_CHAR_WEIGHT:
849cdf0e10cSrcweir 					    aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight;
850cdf0e10cSrcweir 					    break;
851cdf0e10cSrcweir 				    case SID_ATTR_CHAR_POSTURE:
852cdf0e10cSrcweir 					    aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
853cdf0e10cSrcweir 					    break;
854cdf0e10cSrcweir 				    case SID_ATTR_CHAR_UNDERLINE:
855cdf0e10cSrcweir 					    aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
856cdf0e10cSrcweir 					    break;
857cdf0e10cSrcweir 				    default:
858cdf0e10cSrcweir 					    ;
859cdf0e10cSrcweir 			        } // switch(_nCommand)
860cdf0e10cSrcweir             }
861cdf0e10cSrcweir 			break;
862cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR:
863cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR2:
864cdf0e10cSrcweir             impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn);
865cdf0e10cSrcweir 			break;
866cdf0e10cSrcweir         case SID_ATTR_CHAR_FONT:
867cdf0e10cSrcweir             impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
868cdf0e10cSrcweir             break;
869cdf0e10cSrcweir         case SID_ATTR_CHAR_FONTHEIGHT:
870cdf0e10cSrcweir             impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn);
871cdf0e10cSrcweir             if ( aReturn.aValue.hasValue() )
872cdf0e10cSrcweir             {
873cdf0e10cSrcweir                 frame::status::FontHeight aFontHeight;
874cdf0e10cSrcweir                 aReturn.aValue >>= aFontHeight.Height;
875cdf0e10cSrcweir                 aReturn.aValue <<= aFontHeight; // another type is needed here, so
876cdf0e10cSrcweir             }
877cdf0e10cSrcweir             break;
878cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_LEFT:
879cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_CENTER:
880cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_RIGHT:
881cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_BLOCK:
882cdf0e10cSrcweir             impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn);
883cdf0e10cSrcweir             if ( aReturn.bEnabled )
884cdf0e10cSrcweir             {
885cdf0e10cSrcweir                 ::sal_Int16 nParaAdjust = 0;
886cdf0e10cSrcweir                 if ( aReturn.aValue >>= nParaAdjust )
887cdf0e10cSrcweir                 {
888cdf0e10cSrcweir                     switch(nParaAdjust)
889cdf0e10cSrcweir                     {
890cdf0e10cSrcweir                         case style::ParagraphAdjust_LEFT:
891cdf0e10cSrcweir                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT;
892cdf0e10cSrcweir                             break;
893cdf0e10cSrcweir                         case style::ParagraphAdjust_RIGHT:
894cdf0e10cSrcweir                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT;
895cdf0e10cSrcweir                             break;
896cdf0e10cSrcweir                         case style::ParagraphAdjust_BLOCK:
897cdf0e10cSrcweir                         case style::ParagraphAdjust_STRETCH:
898cdf0e10cSrcweir                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK;
899cdf0e10cSrcweir                             break;
900cdf0e10cSrcweir                         case style::ParagraphAdjust_CENTER:
901cdf0e10cSrcweir                             aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER;
902cdf0e10cSrcweir                             break;
903cdf0e10cSrcweir                     }
904cdf0e10cSrcweir                 } // if ( aReturn.aValue >>= nParaAdjust )
905cdf0e10cSrcweir                 aReturn.aValue.clear();
906cdf0e10cSrcweir             }
907cdf0e10cSrcweir             break;
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 		case SID_INSERT_GRAPHIC:
910cdf0e10cSrcweir             aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
911cdf0e10cSrcweir 			break;
912cdf0e10cSrcweir         case SID_CHAR_DLG:
913cdf0e10cSrcweir 		case SID_SETCONTROLDEFAULTS:
914cdf0e10cSrcweir 			aReturn.bEnabled = m_xReportDefinition.is() && isEditable();// && getDesignView()->getCurrentControlModel().is();
915cdf0e10cSrcweir             if ( aReturn.bEnabled )
916cdf0e10cSrcweir             {
917cdf0e10cSrcweir                 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
918cdf0e10cSrcweir                 getDesignView()->fillControlModelSelection(aSelection);
919cdf0e10cSrcweir                 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
920cdf0e10cSrcweir                 for(; aIter != aSelection.end()
921cdf0e10cSrcweir                     && !uno::Reference< report::XFixedLine >(*aIter,uno::UNO_QUERY).is()
922cdf0e10cSrcweir                     && !uno::Reference< report::XImageControl >(*aIter,uno::UNO_QUERY).is()
923cdf0e10cSrcweir                     && uno::Reference< report::XReportControlFormat >(*aIter,uno::UNO_QUERY).is() ;++aIter)
924cdf0e10cSrcweir                     ;
925cdf0e10cSrcweir                 aReturn.bEnabled = !aSelection.empty() && aIter == aSelection.end();
926cdf0e10cSrcweir             }
927cdf0e10cSrcweir 			break;
928cdf0e10cSrcweir 		case SID_CONDITIONALFORMATTING:
929cdf0e10cSrcweir 			{
930cdf0e10cSrcweir                 const uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
931cdf0e10cSrcweir 				aReturn.bEnabled = xFormattedField.is();
932cdf0e10cSrcweir 			}
933cdf0e10cSrcweir 			break;
934cdf0e10cSrcweir 		case SID_INSERT_FLD_PGNUMBER:
935cdf0e10cSrcweir 		case SID_DATETIME:
936cdf0e10cSrcweir 			aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
937cdf0e10cSrcweir 			break;
938cdf0e10cSrcweir 		case SID_EXPORTDOC:
939cdf0e10cSrcweir 		case SID_EXPORTDOCASPDF:
940cdf0e10cSrcweir 			aReturn.bEnabled = m_xReportDefinition.is();
941cdf0e10cSrcweir 			break;
942cdf0e10cSrcweir 		case SID_PRINTPREVIEW:
943cdf0e10cSrcweir             aReturn.bEnabled = sal_False;
944cdf0e10cSrcweir 			break;
945cdf0e10cSrcweir         case SID_ATTR_ZOOM:
946cdf0e10cSrcweir             aReturn.bEnabled = sal_True;
947cdf0e10cSrcweir             {
948cdf0e10cSrcweir                 SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
949cdf0e10cSrcweir                 aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200);
950cdf0e10cSrcweir                 aZoom.QueryValue(aReturn.aValue);
951cdf0e10cSrcweir                 //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue);
952cdf0e10cSrcweir             }
953cdf0e10cSrcweir             break;
954cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER:
955cdf0e10cSrcweir             aReturn.bEnabled = sal_True;
956cdf0e10cSrcweir             {
957cdf0e10cSrcweir                 SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400);
958cdf0e10cSrcweir                 aZoomSlider.AddSnappingPoint(50);
959cdf0e10cSrcweir                 aZoomSlider.AddSnappingPoint(75);
960cdf0e10cSrcweir                 aZoomSlider.AddSnappingPoint(100);
961cdf0e10cSrcweir                 aZoomSlider.AddSnappingPoint(200);
962cdf0e10cSrcweir                 aZoomSlider.QueryValue(aReturn.aValue);
963cdf0e10cSrcweir                 //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue);
964cdf0e10cSrcweir             }
965cdf0e10cSrcweir 			break;
966cdf0e10cSrcweir 		default:
967cdf0e10cSrcweir 			aReturn = OReportController_BASE::GetState(_nId);
968cdf0e10cSrcweir 	}
969cdf0e10cSrcweir 	return aReturn;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir // -----------------------------------------------------------------------------
973cdf0e10cSrcweir namespace
974cdf0e10cSrcweir {
975cdf0e10cSrcweir     /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call
976cdf0e10cSrcweir 
977cdf0e10cSrcweir         The dispatch might originate from either the toolbar, or the conditional
978cdf0e10cSrcweir         formatting dialog. In both cases, argument formats are different.
979cdf0e10cSrcweir     */
lcl_extractBackgroundColor(const Sequence<PropertyValue> & _rDispatchArgs)980cdf0e10cSrcweir     util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs )
981cdf0e10cSrcweir     {
982cdf0e10cSrcweir 		util::Color aColor( COL_TRANSPARENT );
983cdf0e10cSrcweir         if ( _rDispatchArgs.getLength() == 1 )
984cdf0e10cSrcweir         {
985cdf0e10cSrcweir             OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor );
986cdf0e10cSrcweir         }
987cdf0e10cSrcweir         else
988cdf0e10cSrcweir         {
989cdf0e10cSrcweir 			SequenceAsHashMap aMap( _rDispatchArgs );
990cdf0e10cSrcweir             aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor );
991cdf0e10cSrcweir         }
992cdf0e10cSrcweir         return aColor;
993cdf0e10cSrcweir     }
994cdf0e10cSrcweir }
995cdf0e10cSrcweir 
996cdf0e10cSrcweir // -----------------------------------------------------------------------------
Execute(sal_uInt16 _nId,const Sequence<PropertyValue> & aArgs)997cdf0e10cSrcweir void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
998cdf0e10cSrcweir {
999cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1000cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir     sal_Bool bForceBroadcast = sal_False;
1003cdf0e10cSrcweir 	switch(_nId)
1004cdf0e10cSrcweir 	{
1005cdf0e10cSrcweir         case SID_RPT_TEXTDOCUMENT:
1006cdf0e10cSrcweir             if ( m_xReportDefinition.is() )
1007cdf0e10cSrcweir                 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT );
1008cdf0e10cSrcweir             break;
1009cdf0e10cSrcweir         case SID_RPT_SPREADSHEET:
1010cdf0e10cSrcweir             if (m_xReportDefinition.is() )
1011cdf0e10cSrcweir                 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET );
1012cdf0e10cSrcweir             break;
1013cdf0e10cSrcweir 		case SID_REPORTHEADER_WITHOUT_UNDO:
1014cdf0e10cSrcweir 		case SID_REPORTFOOTER_WITHOUT_UNDO:
1015cdf0e10cSrcweir 		case SID_REPORTHEADERFOOTER:
1016cdf0e10cSrcweir             switchReportSection(_nId);
1017cdf0e10cSrcweir 			break;
1018cdf0e10cSrcweir 		case SID_PAGEHEADER_WITHOUT_UNDO:
1019cdf0e10cSrcweir 		case SID_PAGEFOOTER_WITHOUT_UNDO:
1020cdf0e10cSrcweir 		case SID_PAGEHEADERFOOTER:
1021cdf0e10cSrcweir             switchPageSection(_nId);
1022cdf0e10cSrcweir 			break;
1023cdf0e10cSrcweir 		case SID_GROUP_APPEND:
1024cdf0e10cSrcweir 		case SID_GROUP_REMOVE:
1025cdf0e10cSrcweir             modifyGroup(_nId == SID_GROUP_APPEND,aArgs);
1026cdf0e10cSrcweir 			break;
1027cdf0e10cSrcweir 		case SID_GROUPHEADER_WITHOUT_UNDO:
1028cdf0e10cSrcweir 		case SID_GROUPHEADER:
1029cdf0e10cSrcweir             createGroupSection(SID_GROUPHEADER == _nId,true,aArgs);
1030cdf0e10cSrcweir 			break;
1031cdf0e10cSrcweir 		case SID_GROUPFOOTER_WITHOUT_UNDO:
1032cdf0e10cSrcweir 		case SID_GROUPFOOTER:
1033cdf0e10cSrcweir             createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs);
1034cdf0e10cSrcweir 			break;
1035cdf0e10cSrcweir 		case SID_ADD_CONTROL_PAIR:
1036cdf0e10cSrcweir             addPairControls(aArgs);
1037cdf0e10cSrcweir 			break;
1038cdf0e10cSrcweir 		case SID_REDO:
1039cdf0e10cSrcweir         case SID_UNDO:
1040cdf0e10cSrcweir         {
1041cdf0e10cSrcweir             const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() );
1042cdf0e10cSrcweir             sal_Bool ( SfxUndoManager::*doXDo )() =
1043cdf0e10cSrcweir                 ( _nId == SID_UNDO ) ? &SfxUndoManager::Undo : &SfxUndoManager::Redo;
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir             SfxUndoManager& rUndoManager( getUndoManager() );
1046cdf0e10cSrcweir             (rUndoManager.*doXDo)();
1047cdf0e10cSrcweir             InvalidateAll();
1048cdf0e10cSrcweir             updateFloater();
1049cdf0e10cSrcweir         }
1050cdf0e10cSrcweir 		break;
1051cdf0e10cSrcweir 		case SID_CUT:
1052cdf0e10cSrcweir             executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Cut));
1053cdf0e10cSrcweir 			break;
1054cdf0e10cSrcweir 		case SID_COPY:
1055cdf0e10cSrcweir 			getDesignView()->Copy();
1056cdf0e10cSrcweir 			break;
1057cdf0e10cSrcweir 		case SID_PASTE:
1058cdf0e10cSrcweir             executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fun(&ODesignView::Paste));
1059cdf0e10cSrcweir 			break;
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir         case SID_FRAME_TO_TOP:
1062cdf0e10cSrcweir         case SID_FRAME_DOWN:
1063cdf0e10cSrcweir         case SID_FRAME_UP:
1064cdf0e10cSrcweir         case SID_FRAME_TO_BOTTOM:
1065cdf0e10cSrcweir         case SID_OBJECT_HEAVEN:
1066cdf0e10cSrcweir         case SID_OBJECT_HELL:
1067cdf0e10cSrcweir             changeZOrder(_nId);
1068cdf0e10cSrcweir 			break;
1069cdf0e10cSrcweir         case SID_DISTRIBUTION:
1070cdf0e10cSrcweir             {
1071cdf0e10cSrcweir                 OSectionView* pSectionView = getCurrentSectionView();
1072cdf0e10cSrcweir                 if ( pSectionView )
1073cdf0e10cSrcweir                     pSectionView->DistributeMarkedObjects();
1074cdf0e10cSrcweir             }
1075cdf0e10cSrcweir             break;
1076cdf0e10cSrcweir         case SID_OBJECT_SMALLESTWIDTH:
1077cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST);
1078cdf0e10cSrcweir             break;
1079cdf0e10cSrcweir         case SID_OBJECT_SMALLESTHEIGHT:
1080cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST);
1081cdf0e10cSrcweir             break;
1082cdf0e10cSrcweir         case SID_OBJECT_GREATESTWIDTH:
1083cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST);
1084cdf0e10cSrcweir             break;
1085cdf0e10cSrcweir         case SID_OBJECT_GREATESTHEIGHT:
1086cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST);
1087cdf0e10cSrcweir             break;
1088cdf0e10cSrcweir         case SID_SECTION_ALIGN_LEFT:
1089cdf0e10cSrcweir         case SID_OBJECT_ALIGN_LEFT:
1090cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId);
1091cdf0e10cSrcweir 			break;
1092cdf0e10cSrcweir         case SID_SECTION_ALIGN_CENTER:
1093cdf0e10cSrcweir         case SID_OBJECT_ALIGN_CENTER:
1094cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId);
1095cdf0e10cSrcweir 			break;
1096cdf0e10cSrcweir         case SID_SECTION_ALIGN_RIGHT:
1097cdf0e10cSrcweir         case SID_OBJECT_ALIGN_RIGHT:
1098cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId);
1099cdf0e10cSrcweir 			break;
1100cdf0e10cSrcweir         case SID_SECTION_ALIGN_UP:
1101cdf0e10cSrcweir         case SID_OBJECT_ALIGN_UP:
1102cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId);
1103cdf0e10cSrcweir 			break;
1104cdf0e10cSrcweir         case SID_SECTION_ALIGN_MIDDLE:
1105cdf0e10cSrcweir         case SID_OBJECT_ALIGN_MIDDLE:
1106cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId);
1107cdf0e10cSrcweir 			break;
1108cdf0e10cSrcweir         case SID_SECTION_ALIGN_DOWN:
1109cdf0e10cSrcweir         case SID_OBJECT_ALIGN_DOWN:
1110cdf0e10cSrcweir             alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId);
1111cdf0e10cSrcweir 			break;
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir         case SID_SECTION_SHRINK_BOTTOM:
1114cdf0e10cSrcweir         case SID_SECTION_SHRINK_TOP:
1115cdf0e10cSrcweir         case SID_SECTION_SHRINK:
1116cdf0e10cSrcweir             {
1117cdf0e10cSrcweir         		uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
1118cdf0e10cSrcweir                 shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId);
1119cdf0e10cSrcweir             }
1120cdf0e10cSrcweir             break;
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir         case SID_SELECTALL:
1123cdf0e10cSrcweir 			getDesignView()->SelectAll(OBJ_NONE);
1124cdf0e10cSrcweir 			break;
1125cdf0e10cSrcweir         case SID_SELECTALL_IN_SECTION:
1126cdf0e10cSrcweir             {
1127cdf0e10cSrcweir                 OSectionView* pSectionView = getCurrentSectionView();
1128cdf0e10cSrcweir                 if ( pSectionView )
1129cdf0e10cSrcweir                     pSectionView->MarkAll();
1130cdf0e10cSrcweir             }
1131cdf0e10cSrcweir             break;
1132cdf0e10cSrcweir         case SID_ESCAPE:
1133cdf0e10cSrcweir             getDesignView()->SetMode(RPTUI_SELECT);
1134cdf0e10cSrcweir             InvalidateFeature( SID_OBJECT_SELECT );
1135cdf0e10cSrcweir             break;
1136cdf0e10cSrcweir         case SID_SELECT_ALL_EDITS:
1137cdf0e10cSrcweir             getDesignView()->SelectAll(OBJ_DLG_FORMATTEDFIELD);
1138cdf0e10cSrcweir             break;
1139cdf0e10cSrcweir         case SID_SELECT_ALL_LABELS:
1140cdf0e10cSrcweir             getDesignView()->SelectAll(OBJ_DLG_FIXEDTEXT);
1141cdf0e10cSrcweir             break;
1142cdf0e10cSrcweir         case SID_TERMINATE_INPLACEACTIVATION:
1143cdf0e10cSrcweir             {
1144cdf0e10cSrcweir                 ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
1145cdf0e10cSrcweir                 if ( pSection )
1146cdf0e10cSrcweir                     pSection->getReportSection().deactivateOle();
1147cdf0e10cSrcweir             }
1148cdf0e10cSrcweir             break;
1149cdf0e10cSrcweir         case SID_SELECT:
1150cdf0e10cSrcweir             if ( aArgs.getLength() == 1 )
1151cdf0e10cSrcweir                 select(aArgs[0].Value);
1152cdf0e10cSrcweir             break;
1153cdf0e10cSrcweir 		case SID_SELECT_REPORT:
1154cdf0e10cSrcweir             select(uno::makeAny(m_xReportDefinition));
1155cdf0e10cSrcweir 			break;
1156cdf0e10cSrcweir         case SID_EXECUTE_REPORT:
1157cdf0e10cSrcweir             /*m_nExecuteReportEvent = */getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport));
1158cdf0e10cSrcweir             break;
1159cdf0e10cSrcweir         case SID_RPT_NEW_FUNCTION:
1160cdf0e10cSrcweir             createNewFunction(aArgs[0].Value);
1161cdf0e10cSrcweir             break;
1162cdf0e10cSrcweir         case SID_COLLAPSE_SECTION:
1163cdf0e10cSrcweir             collapseSection(true);
1164cdf0e10cSrcweir             break;
1165cdf0e10cSrcweir         case SID_EXPAND_SECTION:
1166cdf0e10cSrcweir             collapseSection(false);
1167cdf0e10cSrcweir             break;
1168cdf0e10cSrcweir         case SID_NEXT_MARK:
1169cdf0e10cSrcweir             markSection(true);
1170cdf0e10cSrcweir             break;
1171cdf0e10cSrcweir         case SID_PREV_MARK:
1172cdf0e10cSrcweir             markSection(false);
1173cdf0e10cSrcweir             break;
1174cdf0e10cSrcweir 		case SID_DELETE:
1175cdf0e10cSrcweir             if ( aArgs.getLength() == 1 )
1176cdf0e10cSrcweir             {
1177cdf0e10cSrcweir                 uno::Reference< report::XFunction> xFunction;
1178cdf0e10cSrcweir                 aArgs[0].Value >>= xFunction;
1179cdf0e10cSrcweir                 if ( xFunction.is() )
1180cdf0e10cSrcweir                 {
1181cdf0e10cSrcweir                     uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW);
1182cdf0e10cSrcweir                     sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction);
1183cdf0e10cSrcweir                     const String sUndoAction = String((ModuleRes(RID_STR_UNDO_REMOVE_FUNCTION)));
1184cdf0e10cSrcweir                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
1185cdf0e10cSrcweir                     xFunctions->removeByIndex(nIndex);
1186cdf0e10cSrcweir                     select(uno::makeAny(xFunctions->getParent()));
1187cdf0e10cSrcweir 	                InvalidateFeature( SID_SAVEDOC );
1188cdf0e10cSrcweir 	                InvalidateFeature( SID_UNDO );
1189cdf0e10cSrcweir                 }
1190cdf0e10cSrcweir             }
1191cdf0e10cSrcweir             else
1192cdf0e10cSrcweir                 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Delete));
1193cdf0e10cSrcweir 			break;
1194cdf0e10cSrcweir 		case SID_GRID_USE:
1195cdf0e10cSrcweir             getDesignView()->setGridSnap(m_bGridUse = !m_bGridUse);
1196cdf0e10cSrcweir 			break;
1197cdf0e10cSrcweir         case SID_HELPLINES_MOVE:
1198cdf0e10cSrcweir             getDesignView()->setDragStripes(m_bHelplinesMove = !m_bHelplinesMove);
1199cdf0e10cSrcweir             break;
1200cdf0e10cSrcweir 		case SID_GRID_VISIBLE:
1201cdf0e10cSrcweir 			getDesignView()->toggleGrid(m_bGridVisible = !m_bGridVisible);
1202cdf0e10cSrcweir 			break;
1203cdf0e10cSrcweir 		case SID_RULER:
1204cdf0e10cSrcweir 			getDesignView()->showRuler(m_bShowRuler = !m_bShowRuler);
1205cdf0e10cSrcweir 			break;
1206cdf0e10cSrcweir 		case SID_OBJECT_SELECT:
1207cdf0e10cSrcweir 			getDesignView()->SetMode(RPTUI_SELECT);
1208cdf0e10cSrcweir 			InvalidateAll();
1209cdf0e10cSrcweir 			break;
1210cdf0e10cSrcweir         case SID_INSERT_DIAGRAM:
1211cdf0e10cSrcweir             getDesignView()->SetMode( RPTUI_INSERT );
1212cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_OLE2);
1213cdf0e10cSrcweir             createDefaultControl(aArgs);
1214cdf0e10cSrcweir 			InvalidateAll();
1215cdf0e10cSrcweir             break;
1216cdf0e10cSrcweir 		case SID_FM_FIXEDTEXT:
1217cdf0e10cSrcweir 			getDesignView()->SetMode( RPTUI_INSERT );
1218cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_DLG_FIXEDTEXT );
1219cdf0e10cSrcweir             createDefaultControl(aArgs);
1220cdf0e10cSrcweir 			InvalidateAll();
1221cdf0e10cSrcweir 			break;
1222cdf0e10cSrcweir         case SID_INSERT_HFIXEDLINE:
1223cdf0e10cSrcweir 			getDesignView()->SetMode( RPTUI_INSERT );
1224cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_DLG_HFIXEDLINE );
1225cdf0e10cSrcweir             createDefaultControl(aArgs);
1226cdf0e10cSrcweir 			InvalidateAll();
1227cdf0e10cSrcweir 			break;
1228cdf0e10cSrcweir         case SID_INSERT_VFIXEDLINE:
1229cdf0e10cSrcweir 			getDesignView()->SetMode( RPTUI_INSERT );
1230cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_DLG_VFIXEDLINE );
1231cdf0e10cSrcweir             createDefaultControl(aArgs);
1232cdf0e10cSrcweir 			InvalidateAll();
1233cdf0e10cSrcweir 			break;
1234cdf0e10cSrcweir 		case SID_FM_EDIT:
1235cdf0e10cSrcweir 			getDesignView()->SetMode( RPTUI_INSERT );
1236cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
1237cdf0e10cSrcweir             createDefaultControl(aArgs);
1238cdf0e10cSrcweir 			InvalidateAll();
1239cdf0e10cSrcweir 			break;
1240cdf0e10cSrcweir 		case SID_FM_IMAGECONTROL:
1241cdf0e10cSrcweir 			getDesignView()->SetMode( RPTUI_INSERT );
1242cdf0e10cSrcweir 			getDesignView()->SetInsertObj( OBJ_DLG_IMAGECONTROL );
1243cdf0e10cSrcweir             createDefaultControl(aArgs);
1244cdf0e10cSrcweir 			InvalidateAll();
1245cdf0e10cSrcweir 			break;
1246cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC:
1247cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC1:
1248cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC2:
1249cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC3:
1250cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC4:
1251cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC5:
1252cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC6:
1253cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC7:
1254cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC8:
1255cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC9:
1256cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC10:
1257cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC11:
1258cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC12:
1259cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC13:
1260cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC14:
1261cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC15:
1262cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC16:
1263cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC17:
1264cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC18:
1265cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC19:
1266cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC20:
1267cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC21:
1268cdf0e10cSrcweir         case SID_DRAWTBX_CS_BASIC22:
1269cdf0e10cSrcweir         case SID_DRAWTBX_CS_SYMBOL1:
1270cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL2:
1271cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL3:
1272cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL4:
1273cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL5:
1274cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL6:
1275cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL7:
1276cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL8:
1277cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL9:
1278cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL10:
1279cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL11:
1280cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL12:
1281cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL13:
1282cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL14:
1283cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL15:
1284cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL16:
1285cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL17:
1286cdf0e10cSrcweir 		case SID_DRAWTBX_CS_SYMBOL18:
1287cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW1:
1288cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW2:
1289cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW3:
1290cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW4:
1291cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW5:
1292cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW6:
1293cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW7:
1294cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW8:
1295cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW9:
1296cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW10:
1297cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW11:
1298cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW12:
1299cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW13:
1300cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW14:
1301cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW15:
1302cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW16:
1303cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW17:
1304cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW18:
1305cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW19:
1306cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW20:
1307cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW21:
1308cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW22:
1309cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW23:
1310cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW24:
1311cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW25:
1312cdf0e10cSrcweir 		case SID_DRAWTBX_CS_ARROW26:
1313cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR1:
1314cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR2:
1315cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR3:
1316cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR4:
1317cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR5:
1318cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR6:
1319cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR7:
1320cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR8:
1321cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR9:
1322cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR10:
1323cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR11:
1324cdf0e10cSrcweir 		case SID_DRAWTBX_CS_STAR12:
1325cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART1:
1326cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART2:
1327cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART3:
1328cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART4:
1329cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART5:
1330cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART6:
1331cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART7:
1332cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART8:
1333cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART9:
1334cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART10:
1335cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART11:
1336cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART12:
1337cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART13:
1338cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART14:
1339cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART15:
1340cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART16:
1341cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART17:
1342cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART18:
1343cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART19:
1344cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART20:
1345cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART21:
1346cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART22:
1347cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART23:
1348cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART24:
1349cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART25:
1350cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART26:
1351cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART27:
1352cdf0e10cSrcweir 		case SID_DRAWTBX_CS_FLOWCHART28:
1353cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT1:
1354cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT2:
1355cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT3:
1356cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT4:
1357cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT5:
1358cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT6:
1359cdf0e10cSrcweir 		case SID_DRAWTBX_CS_CALLOUT7:
1360cdf0e10cSrcweir         case SID_DRAWTBX_CS_SYMBOL:
1361cdf0e10cSrcweir         case SID_DRAWTBX_CS_ARROW:
1362cdf0e10cSrcweir         case SID_DRAWTBX_CS_FLOWCHART:
1363cdf0e10cSrcweir         case SID_DRAWTBX_CS_CALLOUT:
1364cdf0e10cSrcweir         case SID_DRAWTBX_CS_STAR:
1365cdf0e10cSrcweir             getDesignView()->SetMode( RPTUI_INSERT );
1366cdf0e10cSrcweir             {
1367cdf0e10cSrcweir                 URL aUrl = getURLForId(_nId);
1368cdf0e10cSrcweir                 sal_Int32 nIndex = 1;
1369cdf0e10cSrcweir                 ::rtl::OUString sType = aUrl.Complete.getToken(0,'.',nIndex);
1370cdf0e10cSrcweir                 if ( nIndex == -1 || !sType.getLength() )
1371cdf0e10cSrcweir                 {
1372cdf0e10cSrcweir                     switch(_nId)
1373cdf0e10cSrcweir                     {
1374cdf0e10cSrcweir                         case SID_DRAWTBX_CS_SYMBOL:
1375cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smiley"));
1376cdf0e10cSrcweir                             break;
1377cdf0e10cSrcweir                         case SID_DRAWTBX_CS_ARROW:
1378cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("left-right-arrow"));
1379cdf0e10cSrcweir                             break;
1380cdf0e10cSrcweir                         case SID_DRAWTBX_CS_FLOWCHART:
1381cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("flowchart-internal-storage"));
1382cdf0e10cSrcweir                             break;
1383cdf0e10cSrcweir                         case SID_DRAWTBX_CS_CALLOUT:
1384cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("round-rectangular-callout"));
1385cdf0e10cSrcweir                             break;
1386cdf0e10cSrcweir                         case SID_DRAWTBX_CS_STAR:
1387cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("star5"));
1388cdf0e10cSrcweir                             break;
1389cdf0e10cSrcweir                         case SID_DRAWTBX_CS_BASIC:
1390cdf0e10cSrcweir                         default:
1391cdf0e10cSrcweir                             sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond"));
1392cdf0e10cSrcweir                     }
1393cdf0e10cSrcweir                 }
1394cdf0e10cSrcweir                 else
1395cdf0e10cSrcweir                     sType = aUrl.Complete.getToken(0,'.',nIndex);
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir 			    getDesignView()->SetInsertObj( OBJ_CUSTOMSHAPE ,sType);
1398cdf0e10cSrcweir                 createDefaultControl(aArgs);
1399cdf0e10cSrcweir             }
1400cdf0e10cSrcweir             InvalidateAll();
1401cdf0e10cSrcweir             break;
1402cdf0e10cSrcweir         case SID_RPT_SHOWREPORTEXPLORER:
1403cdf0e10cSrcweir 			if ( isUiVisible() )
1404cdf0e10cSrcweir 	            getDesignView()->toggleReportExplorer();
1405cdf0e10cSrcweir             break;
1406cdf0e10cSrcweir 		case SID_FM_ADD_FIELD:
1407cdf0e10cSrcweir 			if ( isUiVisible() )
1408cdf0e10cSrcweir 				getDesignView()->toggleAddField();
1409cdf0e10cSrcweir 			break;
1410cdf0e10cSrcweir 		case SID_SHOW_PROPERTYBROWSER:
1411cdf0e10cSrcweir             if ( m_bShowProperties )
1412cdf0e10cSrcweir                 m_sLastActivePage = getDesignView()->getCurrentPage();
1413cdf0e10cSrcweir             else
1414cdf0e10cSrcweir                 getDesignView()->setCurrentPage(m_sLastActivePage);
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 			if ( isUiVisible() )
1417cdf0e10cSrcweir 			{
1418cdf0e10cSrcweir 	            m_bShowProperties = !m_bShowProperties;
1419cdf0e10cSrcweir     	        if ( aArgs.getLength() == 1 )
1420cdf0e10cSrcweir         	        aArgs[0].Value >>= m_bShowProperties;
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir 				getDesignView()->togglePropertyBrowser(m_bShowProperties);
1423cdf0e10cSrcweir 			}
1424cdf0e10cSrcweir 			break;
1425cdf0e10cSrcweir         case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do
1426cdf0e10cSrcweir             m_sLastActivePage = getDesignView()->getCurrentPage();
1427cdf0e10cSrcweir             break;
1428cdf0e10cSrcweir         case SID_SPLIT_POSITION:
1429cdf0e10cSrcweir             getDesignView()->Resize();
1430cdf0e10cSrcweir             break;
1431cdf0e10cSrcweir 		case SID_PAGEDIALOG:
1432cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR_BACKGROUND:
1433cdf0e10cSrcweir 			{
1434cdf0e10cSrcweir 				uno::Reference<report::XSection> xSection;
1435cdf0e10cSrcweir 				if (aArgs.getLength() == 1 )
1436cdf0e10cSrcweir 					aArgs[0].Value >>= xSection;
1437cdf0e10cSrcweir 				openPageDialog(xSection);
1438cdf0e10cSrcweir                 bForceBroadcast = sal_True;
1439cdf0e10cSrcweir 			}
1440cdf0e10cSrcweir 			break;
1441cdf0e10cSrcweir 		case SID_SORTINGANDGROUPING:
1442cdf0e10cSrcweir 			openSortingAndGroupingDialog();
1443cdf0e10cSrcweir             m_bGroupFloaterWasVisible = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
1444cdf0e10cSrcweir 			break;
1445cdf0e10cSrcweir 		case SID_BACKGROUND_COLOR:
1446cdf0e10cSrcweir 			{
1447cdf0e10cSrcweir                 const util::Color aColor( lcl_extractBackgroundColor( aArgs ) );
1448cdf0e10cSrcweir                 if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) )
1449cdf0e10cSrcweir                 {
1450cdf0e10cSrcweir                     uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
1451cdf0e10cSrcweir                     if ( xSection.is() )
1452cdf0e10cSrcweir 		            {
1453cdf0e10cSrcweir 			            xSection->setBackColor( aColor );
1454cdf0e10cSrcweir 		            }
1455cdf0e10cSrcweir                 }
1456cdf0e10cSrcweir                 bForceBroadcast = sal_True;
1457cdf0e10cSrcweir 			}
1458cdf0e10cSrcweir 			break;
1459cdf0e10cSrcweir         case SID_ATTR_CHAR_WEIGHT:
1460cdf0e10cSrcweir 		case SID_ATTR_CHAR_POSTURE:
1461cdf0e10cSrcweir         case SID_ATTR_CHAR_UNDERLINE:
1462cdf0e10cSrcweir 			{
1463cdf0e10cSrcweir 				uno::Reference< awt::XWindow> xWindow;
1464cdf0e10cSrcweir                 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1465cdf0e10cSrcweir                 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir                 const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT));
1468cdf0e10cSrcweir                 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir                 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
1471cdf0e10cSrcweir                 for(; aIter != aControlsFormats.end();++aIter)
1472cdf0e10cSrcweir                 {
1473cdf0e10cSrcweir                     uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY);
1474cdf0e10cSrcweir                     lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
1475cdf0e10cSrcweir                 }
1476cdf0e10cSrcweir 			}
1477cdf0e10cSrcweir 			break;
1478cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR:
1479cdf0e10cSrcweir 		case SID_ATTR_CHAR_COLOR2:
1480cdf0e10cSrcweir 			{
1481cdf0e10cSrcweir                 const SequenceAsHashMap aMap(aArgs);
1482cdf0e10cSrcweir                 const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color());
1483cdf0e10cSrcweir                 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs);
1484cdf0e10cSrcweir                 bForceBroadcast = sal_True;
1485cdf0e10cSrcweir 			}
1486cdf0e10cSrcweir 			break;
1487cdf0e10cSrcweir         case SID_ATTR_CHAR_FONT:
1488cdf0e10cSrcweir             if ( aArgs.getLength() == 1 )
1489cdf0e10cSrcweir             {
1490cdf0e10cSrcweir                 awt::FontDescriptor aFont;
1491cdf0e10cSrcweir                 if ( aArgs[0].Value >>= aFont )
1492cdf0e10cSrcweir                 {
1493cdf0e10cSrcweir                     impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs);
1494cdf0e10cSrcweir                 } // if ( aArgs[0].Value >>= aFont )
1495cdf0e10cSrcweir             }
1496cdf0e10cSrcweir             break;
1497cdf0e10cSrcweir         case SID_ATTR_CHAR_FONTHEIGHT:
1498cdf0e10cSrcweir             if ( aArgs.getLength() == 1 )
1499cdf0e10cSrcweir             {
1500cdf0e10cSrcweir                 float fSelVal = 0.0;
1501cdf0e10cSrcweir                 if ( aArgs[0].Value >>= fSelVal )
1502cdf0e10cSrcweir                     impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs);
1503cdf0e10cSrcweir             }
1504cdf0e10cSrcweir             break;
1505cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_LEFT:
1506cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_CENTER:
1507cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_RIGHT:
1508cdf0e10cSrcweir         case SID_ATTR_PARA_ADJUST_BLOCK:
1509cdf0e10cSrcweir             {
1510cdf0e10cSrcweir                 sal_Int16 eParagraphAdjust = style::ParagraphAdjust_LEFT;
1511cdf0e10cSrcweir                 switch(_nId)
1512cdf0e10cSrcweir                 {
1513cdf0e10cSrcweir                     case SID_ATTR_PARA_ADJUST_LEFT:
1514cdf0e10cSrcweir                         eParagraphAdjust = style::ParagraphAdjust_LEFT;
1515cdf0e10cSrcweir                         break;
1516cdf0e10cSrcweir                     case SID_ATTR_PARA_ADJUST_CENTER:
1517cdf0e10cSrcweir                         eParagraphAdjust = style::ParagraphAdjust_CENTER;
1518cdf0e10cSrcweir                         break;
1519cdf0e10cSrcweir                     case SID_ATTR_PARA_ADJUST_RIGHT:
1520cdf0e10cSrcweir                         eParagraphAdjust = style::ParagraphAdjust_RIGHT;
1521cdf0e10cSrcweir                         break;
1522cdf0e10cSrcweir                     case SID_ATTR_PARA_ADJUST_BLOCK:
1523cdf0e10cSrcweir                         eParagraphAdjust = style::ParagraphAdjust_BLOCK;
1524cdf0e10cSrcweir                         break;
1525cdf0e10cSrcweir                 } // switch(_nId)
1526cdf0e10cSrcweir                 impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(eParagraphAdjust),aArgs);
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir                 InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT);
1529cdf0e10cSrcweir                 InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER);
1530cdf0e10cSrcweir                 InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT);
1531cdf0e10cSrcweir                 InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK);
1532cdf0e10cSrcweir             }
1533cdf0e10cSrcweir             break;
1534cdf0e10cSrcweir 		case SID_CHAR_DLG:
1535cdf0e10cSrcweir 			{
1536cdf0e10cSrcweir                 uno::Sequence< beans::NamedValue > aSettings;
1537cdf0e10cSrcweir 				uno::Reference< awt::XWindow> xWindow;
1538cdf0e10cSrcweir                 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1539cdf0e10cSrcweir                 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1540cdf0e10cSrcweir 
1541cdf0e10cSrcweir                 if ( !aControlsFormats.empty() )
1542cdf0e10cSrcweir                 {
1543cdf0e10cSrcweir                     const String sUndoAction( ModuleRes( RID_STR_UNDO_CHANGEFONT ) );
1544cdf0e10cSrcweir                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
1545cdf0e10cSrcweir 
1546cdf0e10cSrcweir                     ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
1547cdf0e10cSrcweir                     for(; aIter != aControlsFormats.end();++aIter)
1548cdf0e10cSrcweir                     {
1549cdf0e10cSrcweir                         uno::Reference< report::XReportControlFormat > xFormat( *aIter, uno::UNO_QUERY );
1550cdf0e10cSrcweir 				        if ( !xFormat.is() )
1551cdf0e10cSrcweir                             continue;
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir                         if ( aSettings.getLength() == 0 )
1554cdf0e10cSrcweir                         {
1555cdf0e10cSrcweir                             ::rptui::openCharDialog( xFormat, xWindow, aSettings );
1556cdf0e10cSrcweir                             if ( aSettings.getLength() == 0 )
1557cdf0e10cSrcweir                                 break;
1558cdf0e10cSrcweir                         }
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir                         applyCharacterSettings( xFormat, aSettings );
1561cdf0e10cSrcweir                     }
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir                     InvalidateAll();
1564cdf0e10cSrcweir                 }
1565cdf0e10cSrcweir 			}
1566cdf0e10cSrcweir 			break;
1567cdf0e10cSrcweir 		case SID_INSERT_GRAPHIC:
1568cdf0e10cSrcweir             insertGraphic();
1569cdf0e10cSrcweir             break;
1570cdf0e10cSrcweir 		case SID_SETCONTROLDEFAULTS:
1571cdf0e10cSrcweir 			break;
1572cdf0e10cSrcweir 		case SID_CONDITIONALFORMATTING:
1573cdf0e10cSrcweir 			{
1574cdf0e10cSrcweir 				uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
1575cdf0e10cSrcweir 				if ( xFormattedField.is() )
1576cdf0e10cSrcweir 				{
1577cdf0e10cSrcweir 					ConditionalFormattingDialog aDlg( getView(), xFormattedField.get(), *this );
1578cdf0e10cSrcweir 					aDlg.Execute();
1579cdf0e10cSrcweir 				}
1580cdf0e10cSrcweir 			}
1581cdf0e10cSrcweir 			break;
1582cdf0e10cSrcweir 		case SID_DATETIME:
1583cdf0e10cSrcweir 			if ( m_xReportDefinition.is() )
1584cdf0e10cSrcweir 			{
1585cdf0e10cSrcweir                 if ( !aArgs.getLength() )
1586cdf0e10cSrcweir                 {
1587cdf0e10cSrcweir 				    ODateTimeDialog aDlg(getView(),getDesignView()->getCurrentSection(),this);
1588cdf0e10cSrcweir 				    aDlg.Execute();
1589cdf0e10cSrcweir                 }
1590cdf0e10cSrcweir                 else
1591cdf0e10cSrcweir                     createDateTime(aArgs);
1592cdf0e10cSrcweir 			} // if ( m_xReportDefinition.is() )
1593cdf0e10cSrcweir 			break;
1594cdf0e10cSrcweir 		case SID_INSERT_FLD_PGNUMBER:
1595cdf0e10cSrcweir 			if ( m_xReportDefinition.is() )
1596cdf0e10cSrcweir 			{
1597cdf0e10cSrcweir                 if ( !aArgs.getLength() )
1598cdf0e10cSrcweir                 {
1599cdf0e10cSrcweir 				    OPageNumberDialog aDlg(getView(),m_xReportDefinition,this);
1600cdf0e10cSrcweir 				    aDlg.Execute();
1601cdf0e10cSrcweir                 }
1602cdf0e10cSrcweir                 else
1603cdf0e10cSrcweir                     createPageNumber(aArgs);
1604cdf0e10cSrcweir 			} // if ( m_xReportDefinition.is() )
1605cdf0e10cSrcweir 			break;
1606cdf0e10cSrcweir 		case SID_EXPORTDOC:
1607cdf0e10cSrcweir 		case SID_EXPORTDOCASPDF:
1608cdf0e10cSrcweir 			break;
1609cdf0e10cSrcweir 		case SID_PRINTPREVIEW:
1610cdf0e10cSrcweir 			if ( m_xReportDefinition.is() )
1611cdf0e10cSrcweir 			{
1612cdf0e10cSrcweir 			}
1613cdf0e10cSrcweir 			break;
1614cdf0e10cSrcweir 		case SID_EDITDOC:
1615cdf0e10cSrcweir 			if(isEditable())
1616cdf0e10cSrcweir 			{ // the state should be changed to not editable
1617cdf0e10cSrcweir 				switch (saveModified())
1618cdf0e10cSrcweir 				{
1619cdf0e10cSrcweir 					case RET_CANCEL:
1620cdf0e10cSrcweir 						// don't change anything here so return
1621cdf0e10cSrcweir 						return;
1622cdf0e10cSrcweir 					case RET_NO:
1623cdf0e10cSrcweir 						setModified(sal_False);		// and we are not modified yet
1624cdf0e10cSrcweir 						break;
1625cdf0e10cSrcweir 					default:
1626cdf0e10cSrcweir 						break;
1627cdf0e10cSrcweir 				}
1628cdf0e10cSrcweir 			}
1629cdf0e10cSrcweir 			setEditable(!isEditable());
1630cdf0e10cSrcweir 			//getJoinView()->setReadOnly(!isEditable());
1631cdf0e10cSrcweir 			InvalidateAll();
1632cdf0e10cSrcweir 			return;
1633cdf0e10cSrcweir         case SID_GROUP:
1634cdf0e10cSrcweir             break;
1635cdf0e10cSrcweir         case SID_ATTR_ZOOM:
1636cdf0e10cSrcweir             if ( aArgs.getLength() == 0 )
1637cdf0e10cSrcweir             {
1638cdf0e10cSrcweir                 openZoomDialog();
1639cdf0e10cSrcweir             }
1640cdf0e10cSrcweir             else if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") )
1641cdf0e10cSrcweir             {
1642cdf0e10cSrcweir                 SvxZoomItem aZoomItem;
1643cdf0e10cSrcweir                 aZoomItem.PutValue(aArgs[0].Value);
1644cdf0e10cSrcweir                 m_nZoomValue = aZoomItem.GetValue();
1645cdf0e10cSrcweir                 m_eZoomType = aZoomItem.GetType();
1646cdf0e10cSrcweir                 impl_zoom_nothrow();
1647cdf0e10cSrcweir             } // if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") )
1648cdf0e10cSrcweir             break;
1649cdf0e10cSrcweir         case SID_ATTR_ZOOMSLIDER:
1650cdf0e10cSrcweir             if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("ZoomSlider") )
1651cdf0e10cSrcweir             {
1652cdf0e10cSrcweir                 SvxZoomSliderItem aZoomSlider;
1653cdf0e10cSrcweir                 aZoomSlider.PutValue(aArgs[0].Value);
1654cdf0e10cSrcweir                 m_nZoomValue = aZoomSlider.GetValue();
1655cdf0e10cSrcweir                 m_eZoomType = SVX_ZOOM_PERCENT;
1656cdf0e10cSrcweir                 impl_zoom_nothrow();
1657cdf0e10cSrcweir             }
1658cdf0e10cSrcweir 			break;
1659cdf0e10cSrcweir 		default:
1660cdf0e10cSrcweir 			OReportController_BASE::Execute(_nId,aArgs);
1661cdf0e10cSrcweir 	}
1662cdf0e10cSrcweir 	InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast);
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir // -----------------------------------------------------------------------------
saveModified()1665cdf0e10cSrcweir short OReportController::saveModified()
1666cdf0e10cSrcweir {
1667cdf0e10cSrcweir 	return RET_NO;
1668cdf0e10cSrcweir }
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_initialize()1671cdf0e10cSrcweir void OReportController::impl_initialize( )
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir     OReportController_BASE::impl_initialize();
1674cdf0e10cSrcweir 
1675cdf0e10cSrcweir     const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir     rArguments.get_ensureType( (::rtl::OUString)PROPERTY_REPORTNAME, m_sName );
1678cdf0e10cSrcweir     if ( !m_sName.getLength() )
1679cdf0e10cSrcweir         rArguments.get_ensureType( "DocumentTitle", m_sName );
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir 	try
1682cdf0e10cSrcweir 	{
1683cdf0e10cSrcweir 		if ( m_xReportDefinition.is() )
1684cdf0e10cSrcweir 		{
1685cdf0e10cSrcweir 			//m_sName = m_xReportDefinition->getName();
1686cdf0e10cSrcweir 			getView()->initialize();	// show the windows and fill with our informations
1687cdf0e10cSrcweir 
1688cdf0e10cSrcweir             m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
1689cdf0e10cSrcweir             if ( !m_aReportModel )
1690cdf0e10cSrcweir                 throw RuntimeException();
1691cdf0e10cSrcweir             m_aReportModel->attachController( *this );
1692cdf0e10cSrcweir 
1693cdf0e10cSrcweir 		    clearUndoManager();
1694cdf0e10cSrcweir             UndoSuppressor aSuppressUndo( getUndoManager() );
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir             ::comphelper::NamedValueCollection aArgs(getModel()->getArgs());
1697cdf0e10cSrcweir             setMode(aArgs.getOrDefault("Mode", rtl::OUString::createFromAscii("normal")));
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir             listen(true);
1700cdf0e10cSrcweir             setEditable( !m_aReportModel->IsReadOnly() );
1701cdf0e10cSrcweir             m_xFormatter.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
1702cdf0e10cSrcweir             m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY));
1703cdf0e10cSrcweir 
1704cdf0e10cSrcweir             ::comphelper::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() );
1705cdf0e10cSrcweir             ::rtl::OUString sHierarchicalDocumentName;
1706cdf0e10cSrcweir             sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HierarchicalDocumentName")),sHierarchicalDocumentName);
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir             if ( !sHierarchicalDocumentName.getLength() && getConnection().is() )
1709cdf0e10cSrcweir             {
1710cdf0e10cSrcweir                 uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW);
1711cdf0e10cSrcweir                 uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables();
1712cdf0e10cSrcweir                 const uno::Sequence< ::rtl::OUString > aNames( xTables->getElementNames() );
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir                 if ( aNames.hasElements() )
1715cdf0e10cSrcweir                 {
1716cdf0e10cSrcweir                     m_xReportDefinition->setCommand(aNames[0]);
1717cdf0e10cSrcweir                     m_xReportDefinition->setCommandType(sdb::CommandType::TABLE);
1718cdf0e10cSrcweir                 }
1719cdf0e10cSrcweir             } // if ( !sHierarchicalDocumentName.getLength() && getConnection().is() )
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir             m_aVisualAreaSize = m_xReportDefinition->getVisualAreaSize(0);
1722cdf0e10cSrcweir 
1723cdf0e10cSrcweir 		} // if ( m_xReportDefinition.is() )
1724cdf0e10cSrcweir 
1725cdf0e10cSrcweir         // check if chart is supported by the engine
1726cdf0e10cSrcweir         checkChartEnabled();
1727cdf0e10cSrcweir         // restore the view data
1728cdf0e10cSrcweir         getDesignView()->toggleGrid(m_bGridVisible);
1729cdf0e10cSrcweir         getDesignView()->showRuler(m_bShowRuler);
1730cdf0e10cSrcweir         getDesignView()->togglePropertyBrowser(m_bShowProperties);
1731cdf0e10cSrcweir         getDesignView()->setCurrentPage(m_sLastActivePage);
1732cdf0e10cSrcweir         getDesignView()->unmarkAllObjects(NULL);
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir         if ( m_nPageNum != -1 )
1735cdf0e10cSrcweir         {
1736cdf0e10cSrcweir             if ( m_nPageNum < m_aReportModel->GetPageCount() )
1737cdf0e10cSrcweir             {
1738cdf0e10cSrcweir                 const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum)));
1739cdf0e10cSrcweir                 if ( pPage )
1740cdf0e10cSrcweir                 {
1741cdf0e10cSrcweir                     uno::Sequence< beans::PropertyValue> aArgs(1);
1742cdf0e10cSrcweir                     aArgs[0].Value <<= pPage->getSection();
1743cdf0e10cSrcweir                     executeUnChecked(SID_SELECT,aArgs);
1744cdf0e10cSrcweir                 }
1745cdf0e10cSrcweir             }
1746cdf0e10cSrcweir             else
1747cdf0e10cSrcweir                 m_nPageNum = -1;
1748cdf0e10cSrcweir         }
1749cdf0e10cSrcweir         getDesignView()->collapseSections(m_aCollapsedSections);
1750cdf0e10cSrcweir         impl_zoom_nothrow();
1751cdf0e10cSrcweir         getDesignView()->Resize();
1752cdf0e10cSrcweir         getDesignView()->Invalidate();
1753cdf0e10cSrcweir         InvalidateAll();
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir         if ( m_bShowProperties && m_nPageNum == -1 )
1756cdf0e10cSrcweir         {
1757cdf0e10cSrcweir             m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"));
1758cdf0e10cSrcweir             getDesignView()->setCurrentPage(m_sLastActivePage);
1759cdf0e10cSrcweir             uno::Sequence< beans::PropertyValue> aArgs;
1760cdf0e10cSrcweir             executeUnChecked(SID_SELECT_REPORT,aArgs);
1761cdf0e10cSrcweir         } // if ( m_bShowProperties && m_nPageNum == -1 )
1762cdf0e10cSrcweir 
1763cdf0e10cSrcweir 		setModified(sal_False);		// and we are not modified yet
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir 		// open the global help agent
1766cdf0e10cSrcweir 		// we need a Frame but at this time there is no frame, therefore we send a UserEvent
1767cdf0e10cSrcweir 		getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
1768cdf0e10cSrcweir 	}
1769cdf0e10cSrcweir 	catch(const SQLException&)
1770cdf0e10cSrcweir 	{
1771cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
1772cdf0e10cSrcweir 	}
1773cdf0e10cSrcweir }
1774cdf0e10cSrcweir // -----------------------------------------------------------------------------
1775cdf0e10cSrcweir IMPL_LINK( OReportController, OnOpenHelpAgent, void* ,/*_pMemfun*/)
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir     //m_nExecuteReportEvent = 0;
1778cdf0e10cSrcweir     doOpenHelpAgent();
1779cdf0e10cSrcweir     return 0L;
1780cdf0e10cSrcweir }
1781cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OReportController,OnCreateHdl,OAddFieldWindow *,_pAddFieldDlg)1782cdf0e10cSrcweir IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow* ,_pAddFieldDlg)
1783cdf0e10cSrcweir {
1784cdf0e10cSrcweir     WaitObject aObj( getDesignView() );
1785cdf0e10cSrcweir     uno::Sequence< beans::PropertyValue > aArgs = _pAddFieldDlg->getSelectedFieldDescriptors();
1786cdf0e10cSrcweir     // we use this way to create undo actions
1787cdf0e10cSrcweir     if ( aArgs.getLength() )
1788cdf0e10cSrcweir     {
1789cdf0e10cSrcweir         executeChecked(SID_ADD_CONTROL_PAIR,aArgs);
1790cdf0e10cSrcweir     }
1791cdf0e10cSrcweir     return 0L;
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir // -----------------------------------------------------------------------------
1794cdf0e10cSrcweir 
doOpenHelpAgent()1795cdf0e10cSrcweir void OReportController::doOpenHelpAgent()
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir 	if (getFrame().is())
1798cdf0e10cSrcweir 	{
1799cdf0e10cSrcweir 		rtl::OUString suURL = rtl::OUString::createFromAscii("vnd.sun.star.help://shared/text/shared/explorer/database/rep_main.xhp?UseDB=no&DbPAR=swriter");
1800cdf0e10cSrcweir 		openHelpAgent(suURL);
1801cdf0e10cSrcweir 		// openHelpAgent(68245 /* HID_REPORT_DESIGN... UNKNOWN */ );
1802cdf0e10cSrcweir 		// HID_APP_REPORT_TREE
1803cdf0e10cSrcweir 	}
1804cdf0e10cSrcweir 	else
1805cdf0e10cSrcweir 	{
1806cdf0e10cSrcweir         // as long as we don't get a Frame, we send the user event again.
1807cdf0e10cSrcweir 		getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
1808cdf0e10cSrcweir 	}
1809cdf0e10cSrcweir }
1810cdf0e10cSrcweir // -----------------------------------------------------------------------------
Construct(Window * pParent)1811cdf0e10cSrcweir sal_Bool OReportController::Construct(Window* pParent)
1812cdf0e10cSrcweir {
1813cdf0e10cSrcweir 	ODesignView* pMyOwnView = new ODesignView( pParent, getORB(), *this );
1814cdf0e10cSrcweir 	StartListening( *pMyOwnView );
1815cdf0e10cSrcweir     setView( *pMyOwnView );
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir 	// now that we have a view we can create the clipboard listener
1818cdf0e10cSrcweir 	m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
1819cdf0e10cSrcweir 	m_aSystemClipboard.StartClipboardListening( );
1820cdf0e10cSrcweir 	m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) );
1821cdf0e10cSrcweir 	m_pClipbordNotifier->acquire();
1822cdf0e10cSrcweir 	m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir 	OReportController_BASE::Construct(pParent);
1825cdf0e10cSrcweir 	//getView()->Show();
1826cdf0e10cSrcweir 	return sal_True;
1827cdf0e10cSrcweir }
1828cdf0e10cSrcweir // -----------------------------------------------------------------------------
suspend(sal_Bool)1829cdf0e10cSrcweir sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException )
1830cdf0e10cSrcweir {
1831cdf0e10cSrcweir 	if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
1832cdf0e10cSrcweir 		return sal_True;
1833cdf0e10cSrcweir 
1834cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1835cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
1836cdf0e10cSrcweir 
1837cdf0e10cSrcweir     if ( getView() && getView()->IsInModalMode() )
1838cdf0e10cSrcweir         return sal_False;
1839cdf0e10cSrcweir 
1840cdf0e10cSrcweir     // this suspend will be handled in the DBAccess interceptor implementation
1841cdf0e10cSrcweir 	return sal_True;
1842cdf0e10cSrcweir }
1843cdf0e10cSrcweir // -----------------------------------------------------------------------------
describeSupportedFeatures()1844cdf0e10cSrcweir void OReportController::describeSupportedFeatures()
1845cdf0e10cSrcweir {
1846cdf0e10cSrcweir 	DBSubComponentController::describeSupportedFeatures();
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:TextDocument",          	SID_RPT_TEXTDOCUMENT,           CommandGroup::APPLICATION );
1849cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Spreadsheet",          		SID_RPT_SPREADSHEET,   			CommandGroup::APPLICATION );
1850cdf0e10cSrcweir 
1851cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Redo",          			SID_REDO,        				CommandGroup::EDIT );
1852cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Undo",          			SID_UNDO,		 				CommandGroup::EDIT );
1853cdf0e10cSrcweir 	//implDescribeSupportedFeature( ".uno:PasteSpecial",			  SID_PASTE,					CommandGroup::EDIT );
1854cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SelectAll",					SID_SELECTALL,					CommandGroup::EDIT );
1855cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SelectAllInSection",		SID_SELECTALL_IN_SECTION,		CommandGroup::EDIT );
1856cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Delete",					SID_DELETE,						CommandGroup::EDIT );
1857cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SelectReport",				SID_SELECT_REPORT,				CommandGroup::EDIT );
1858cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ExecuteReport",				SID_EXECUTE_REPORT,				CommandGroup::EDIT );
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:GridVisible",				SID_GRID_VISIBLE,				CommandGroup::VIEW );
1861cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:GridUse",    				SID_GRID_USE,   				CommandGroup::VIEW );
1862cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:HelplinesMove", 			SID_HELPLINES_MOVE, 			CommandGroup::VIEW );
1863cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ShowRuler",					SID_RULER,						CommandGroup::VIEW );
1864cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:AddField",					SID_FM_ADD_FIELD,				CommandGroup::VIEW );
1865cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ReportNavigator",		    SID_RPT_SHOWREPORTEXPLORER,	    CommandGroup::VIEW );
1866cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ControlProperties",			SID_SHOW_PROPERTYBROWSER,		CommandGroup::VIEW );
1867cdf0e10cSrcweir 	//implDescribeSupportedFeature( ".uno:SwitchControlDesignMode",	SID_FM_DESIGN_MODE,				CommandGroup::VIEW );
1868cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:DbSortingAndGrouping",		SID_SORTINGANDGROUPING,			CommandGroup::VIEW );
1869cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:PageHeaderFooter",			SID_PAGEHEADERFOOTER,			CommandGroup::VIEW );
1870cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ReportHeaderFooter",		SID_REPORTHEADERFOOTER,			CommandGroup::VIEW );
1871cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ZoomSlider",		        SID_ATTR_ZOOMSLIDER,			CommandGroup::VIEW );
1872cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Zoom",		                SID_ATTR_ZOOM,			        CommandGroup::VIEW );
1873cdf0e10cSrcweir 	//implDescribeSupportedFeature( ".uno:SwitchControlDesignMode",	SID_FM_DESIGN_MODE,				CommandGroup::VIEW );
1874cdf0e10cSrcweir 
1875cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ConditionalFormatting",		SID_CONDITIONALFORMATTING,		CommandGroup::FORMAT );
1876cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:PageDialog",				SID_PAGEDIALOG,					CommandGroup::FORMAT );
1877cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ResetAttributes",		    SID_SETCONTROLDEFAULTS,			CommandGroup::FORMAT );
1878cdf0e10cSrcweir 
1879cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Bold",						SID_ATTR_CHAR_WEIGHT,			CommandGroup::FORMAT );
1880cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Italic",					SID_ATTR_CHAR_POSTURE,			CommandGroup::FORMAT );
1881cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Underline",					SID_ATTR_CHAR_UNDERLINE,		CommandGroup::FORMAT );
1882cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:BackColor",					SID_ATTR_CHAR_COLOR_BACKGROUND,	CommandGroup::FORMAT );
1883cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:BackgroundColor",			SID_BACKGROUND_COLOR,			CommandGroup::FORMAT );
1884cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Color",						SID_ATTR_CHAR_COLOR);
1885cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:FontColor",					SID_ATTR_CHAR_COLOR2,			CommandGroup::FORMAT );
1886cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:FontDialog",				SID_CHAR_DLG,					CommandGroup::FORMAT );
1887cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:LeftPara",				    SID_ATTR_PARA_ADJUST_LEFT,      CommandGroup::FORMAT );
1888cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CenterPara",				SID_ATTR_PARA_ADJUST_CENTER,	CommandGroup::FORMAT );
1889cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:RightPara",				    SID_ATTR_PARA_ADJUST_RIGHT,		CommandGroup::FORMAT );
1890cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:JustifyPara",				SID_ATTR_PARA_ADJUST_BLOCK,		CommandGroup::FORMAT );
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FontHeight",				SID_ATTR_CHAR_FONTHEIGHT,		CommandGroup::FORMAT );
1893cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CharFontName",				SID_ATTR_CHAR_FONT,		        CommandGroup::FORMAT );
1894cdf0e10cSrcweir 
1895cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrangeMenu",			    SID_ARRANGEMENU,			    CommandGroup::FORMAT );
1896cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BringToFront",			    SID_FRAME_TO_TOP,			    CommandGroup::FORMAT );
1897cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectBackOne",				SID_FRAME_DOWN,		            CommandGroup::FORMAT );
1898cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectForwardOne",			SID_FRAME_UP,			        CommandGroup::FORMAT );
1899cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SendToBack",				SID_FRAME_TO_BOTTOM,			CommandGroup::FORMAT );
1900cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SetObjectToForeground",		SID_OBJECT_HEAVEN,			    CommandGroup::FORMAT );
1901cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SetObjectToBackground",		SID_OBJECT_HELL,			    CommandGroup::FORMAT );
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectAlign",			    SID_OBJECT_ALIGN,			    CommandGroup::FORMAT );
1904cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectAlignLeft",			SID_OBJECT_ALIGN_LEFT,			CommandGroup::FORMAT );
1905cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:AlignCenter",				SID_OBJECT_ALIGN_CENTER,		CommandGroup::FORMAT );
1906cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectAlignRight",			SID_OBJECT_ALIGN_RIGHT,			CommandGroup::FORMAT );
1907cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:AlignUp",				    SID_OBJECT_ALIGN_UP,			CommandGroup::FORMAT );
1908cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:AlignMiddle",				SID_OBJECT_ALIGN_MIDDLE,		CommandGroup::FORMAT );
1909cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:AlignDown",			    	SID_OBJECT_ALIGN_DOWN,			CommandGroup::FORMAT );
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlign",			    SID_SECTION_ALIGN,			    CommandGroup::FORMAT );
1912cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignLeft",			SID_SECTION_ALIGN_LEFT,			CommandGroup::FORMAT );
1913cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignCenter",		SID_SECTION_ALIGN_CENTER,		CommandGroup::FORMAT );
1914cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignRight",			SID_SECTION_ALIGN_RIGHT,		CommandGroup::FORMAT );
1915cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignTop",			SID_SECTION_ALIGN_UP,			CommandGroup::FORMAT );
1916cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignMiddle",		SID_SECTION_ALIGN_MIDDLE,		CommandGroup::FORMAT );
1917cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionAlignBottom",		SID_SECTION_ALIGN_DOWN,			CommandGroup::FORMAT );
1918cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionShrink",             SID_SECTION_SHRINK,             CommandGroup::FORMAT );
1919cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionShrinkTop",          SID_SECTION_SHRINK_TOP,         CommandGroup::FORMAT );
1920cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SectionShrinkBottom",       SID_SECTION_SHRINK_BOTTOM,      CommandGroup::FORMAT );
1921cdf0e10cSrcweir 
1922cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ObjectResize",			    SID_OBJECT_RESIZING,		    CommandGroup::FORMAT );
1923cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SmallestWidth",			    SID_OBJECT_SMALLESTWIDTH,		CommandGroup::FORMAT );
1924cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SmallestHeight",			SID_OBJECT_SMALLESTHEIGHT,		CommandGroup::FORMAT );
1925cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:GreatestWidth",			    SID_OBJECT_GREATESTWIDTH,		CommandGroup::FORMAT );
1926cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:GreatestHeight",			SID_OBJECT_GREATESTHEIGHT,		CommandGroup::FORMAT );
1927cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Distribution",		        SID_DISTRIBUTION,		        CommandGroup::FORMAT );
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:HelpMenu",      			SID_HELPMENU,					CommandGroup::APPLICATION );
1930cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ExportTo",      			SID_EXPORTDOC,					CommandGroup::APPLICATION );
1931cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ExportToPDF",   			SID_EXPORTDOCASPDF,				CommandGroup::APPLICATION );
1932cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:PrintPreview",  			SID_PRINTPREVIEW,				CommandGroup::APPLICATION );
1933cdf0e10cSrcweir 
1934cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:NewDoc",        			SID_NEWDOC,      				CommandGroup::DOCUMENT );
1935cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Save",          			SID_SAVEDOC,					CommandGroup::DOCUMENT );
1936cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SaveAs",        			SID_SAVEASDOC,   				CommandGroup::DOCUMENT );
1937cdf0e10cSrcweir 
1938cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:InsertPageNumberField",		SID_INSERT_FLD_PGNUMBER,		CommandGroup::INSERT );
1939cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:InsertDateTimeField",		SID_DATETIME,					CommandGroup::INSERT );
1940cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:InsertObjectChart",			SID_INSERT_DIAGRAM,				CommandGroup::INSERT );
1941cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:InsertGraphic",				SID_INSERT_GRAPHIC,				CommandGroup::INSERT );
1942cdf0e10cSrcweir 	// controls
1943cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SelectObject",				SID_OBJECT_SELECT,				CommandGroup::INSERT );
1944cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Label",						SID_FM_FIXEDTEXT,				CommandGroup::INSERT );
1945cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:Edit",						SID_FM_EDIT,					CommandGroup::INSERT );
1946cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:ImageControl",				SID_FM_IMAGECONTROL,			CommandGroup::INSERT );
1947cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:HFixedLine",			    SID_INSERT_HFIXEDLINE,			CommandGroup::INSERT );
1948cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:VFixedLine",			    SID_INSERT_VFIXEDLINE,			CommandGroup::INSERT );
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir     // shapes
1951cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes",				SID_DRAWTBX_CS_BASIC,			CommandGroup::INSERT );
1952cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.rectangle",     SID_DRAWTBX_CS_BASIC1,			CommandGroup::INSERT );
1953cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2,			CommandGroup::INSERT );
1954cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.quadrat",       SID_DRAWTBX_CS_BASIC3,			CommandGroup::INSERT );
1955cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4,			CommandGroup::INSERT );
1956cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.circle",        SID_DRAWTBX_CS_BASIC5,			CommandGroup::INSERT );
1957cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.ellipse",       SID_DRAWTBX_CS_BASIC6,			CommandGroup::INSERT );
1958cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie",    SID_DRAWTBX_CS_BASIC7,			CommandGroup::INSERT );
1959cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8,		CommandGroup::INSERT );
1960cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9,			CommandGroup::INSERT );
1961cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid",     SID_DRAWTBX_CS_BASIC10,			CommandGroup::INSERT );
1962cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.diamond",       SID_DRAWTBX_CS_BASIC11,			CommandGroup::INSERT );
1963cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12,			CommandGroup::INSERT );
1964cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.pentagon",      SID_DRAWTBX_CS_BASIC13,			CommandGroup::INSERT );
1965cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.hexagon",       SID_DRAWTBX_CS_BASIC14,			CommandGroup::INSERT );
1966cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.octagon",       SID_DRAWTBX_CS_BASIC15,			CommandGroup::INSERT );
1967cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.cross",         SID_DRAWTBX_CS_BASIC16,			CommandGroup::INSERT );
1968cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.ring",          SID_DRAWTBX_CS_BASIC17,			CommandGroup::INSERT );
1969cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.block-arc",     SID_DRAWTBX_CS_BASIC18,			CommandGroup::INSERT );
1970cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.can",           SID_DRAWTBX_CS_BASIC19,			CommandGroup::INSERT );
1971cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.cube",          SID_DRAWTBX_CS_BASIC20,			CommandGroup::INSERT );
1972cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.paper",         SID_DRAWTBX_CS_BASIC21,			CommandGroup::INSERT );
1973cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:BasicShapes.frame",         SID_DRAWTBX_CS_BASIC22,			CommandGroup::INSERT );
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes",				SID_DRAWTBX_CS_SYMBOL,			CommandGroup::INSERT );
1976cdf0e10cSrcweir 
1977cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" ,		SID_DRAWTBX_CS_SYMBOL1,			CommandGroup::INSERT );
1978cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.sun" ,			SID_DRAWTBX_CS_SYMBOL2,			CommandGroup::INSERT );
1979cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.moon" ,		SID_DRAWTBX_CS_SYMBOL3,			CommandGroup::INSERT );
1980cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" ,	SID_DRAWTBX_CS_SYMBOL4,			CommandGroup::INSERT );
1981cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.heart" ,		SID_DRAWTBX_CS_SYMBOL5,			CommandGroup::INSERT );
1982cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.flower" ,		SID_DRAWTBX_CS_SYMBOL6,			CommandGroup::INSERT );
1983cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" ,		SID_DRAWTBX_CS_SYMBOL7,			CommandGroup::INSERT );
1984cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" ,	SID_DRAWTBX_CS_SYMBOL8,			CommandGroup::INSERT );
1985cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" ,		SID_DRAWTBX_CS_SYMBOL9,			CommandGroup::INSERT );
1986cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10,		CommandGroup::INSERT );
1987cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11,		CommandGroup::INSERT );
1988cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12,		CommandGroup::INSERT );
1989cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" ,	SID_DRAWTBX_CS_SYMBOL13,		CommandGroup::INSERT );
1990cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" ,	SID_DRAWTBX_CS_SYMBOL14,		CommandGroup::INSERT );
1991cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" ,	SID_DRAWTBX_CS_SYMBOL15,		CommandGroup::INSERT );
1992cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" ,	SID_DRAWTBX_CS_SYMBOL16,		CommandGroup::INSERT );
1993cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17,		CommandGroup::INSERT );
1994cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18,		CommandGroup::INSERT );
1995cdf0e10cSrcweir 
1996cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" ,	        SID_DRAWTBX_CS_ARROW1,	CommandGroup::INSERT );
1997cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" ,	        SID_DRAWTBX_CS_ARROW2,	CommandGroup::INSERT );
1998cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" ,		        SID_DRAWTBX_CS_ARROW3,	CommandGroup::INSERT );
1999cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" ,	        SID_DRAWTBX_CS_ARROW4,	CommandGroup::INSERT );
2000cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" ,     SID_DRAWTBX_CS_ARROW5,	CommandGroup::INSERT );
2001cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" ,        SID_DRAWTBX_CS_ARROW6,	CommandGroup::INSERT );
2002cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" ,       SID_DRAWTBX_CS_ARROW7,	CommandGroup::INSERT );
2003cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" ,  SID_DRAWTBX_CS_ARROW8,	CommandGroup::INSERT );
2004cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" ,	        SID_DRAWTBX_CS_ARROW9,	CommandGroup::INSERT );
2005cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" ,   SID_DRAWTBX_CS_ARROW10,	CommandGroup::INSERT );
2006cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" ,	        SID_DRAWTBX_CS_ARROW11,	CommandGroup::INSERT );
2007cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" ,  SID_DRAWTBX_CS_ARROW12,	CommandGroup::INSERT );
2008cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" ,  SID_DRAWTBX_CS_ARROW13,	CommandGroup::INSERT );
2009cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" ,	    SID_DRAWTBX_CS_ARROW14,	CommandGroup::INSERT );
2010cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" ,		        SID_DRAWTBX_CS_ARROW15,	CommandGroup::INSERT );
2011cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" ,  SID_DRAWTBX_CS_ARROW16,	CommandGroup::INSERT );
2012cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" ,   SID_DRAWTBX_CS_ARROW17,	CommandGroup::INSERT );
2013cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" ,	    SID_DRAWTBX_CS_ARROW18,	CommandGroup::INSERT );
2014cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" ,   SID_DRAWTBX_CS_ARROW19,	CommandGroup::INSERT );
2015cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20,		CommandGroup::INSERT );
2016cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21,	CommandGroup::INSERT );
2017cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22,	CommandGroup::INSERT );
2018cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" ,	SID_DRAWTBX_CS_ARROW23,	CommandGroup::INSERT );
2019cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" ,		SID_DRAWTBX_CS_ARROW24,	CommandGroup::INSERT );
2020cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" ,	SID_DRAWTBX_CS_ARROW25,	CommandGroup::INSERT );
2021cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" ,		SID_DRAWTBX_CS_ARROW26,	CommandGroup::INSERT );
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.bang" ,			        SID_DRAWTBX_CS_STAR1,			CommandGroup::INSERT );
2024cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star4" ,			        SID_DRAWTBX_CS_STAR2,			CommandGroup::INSERT );
2025cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star5" ,			        SID_DRAWTBX_CS_STAR3,			CommandGroup::INSERT );
2026cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star6" ,			        SID_DRAWTBX_CS_STAR4,			CommandGroup::INSERT );
2027cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star8" ,			        SID_DRAWTBX_CS_STAR5,			CommandGroup::INSERT );
2028cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star12" ,		        SID_DRAWTBX_CS_STAR6,			CommandGroup::INSERT );
2029cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.star24" ,		        SID_DRAWTBX_CS_STAR7,			CommandGroup::INSERT );
2030cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" ,			SID_DRAWTBX_CS_STAR8,			CommandGroup::INSERT );
2031cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" ,		SID_DRAWTBX_CS_STAR9,			CommandGroup::INSERT );
2032cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" ,		SID_DRAWTBX_CS_STAR10,			CommandGroup::INSERT );
2033cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.signet" ,				SID_DRAWTBX_CS_STAR11,			CommandGroup::INSERT );
2034cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes.doorplate" ,				SID_DRAWTBX_CS_STAR12,			CommandGroup::INSERT );
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" ,			SID_DRAWTBX_CS_FLOWCHART1,			CommandGroup::INSERT );
2037cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" ,	SID_DRAWTBX_CS_FLOWCHART2,			CommandGroup::INSERT );
2038cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" ,			SID_DRAWTBX_CS_FLOWCHART3,			CommandGroup::INSERT );
2039cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" ,				SID_DRAWTBX_CS_FLOWCHART4,			CommandGroup::INSERT );
2040cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" ,	SID_DRAWTBX_CS_FLOWCHART5,			CommandGroup::INSERT );
2041cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" ,	SID_DRAWTBX_CS_FLOWCHART6,			CommandGroup::INSERT );
2042cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" ,			SID_DRAWTBX_CS_FLOWCHART7,			CommandGroup::INSERT );
2043cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" ,		SID_DRAWTBX_CS_FLOWCHART8,			CommandGroup::INSERT );
2044cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" ,			SID_DRAWTBX_CS_FLOWCHART9,			CommandGroup::INSERT );
2045cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" ,		SID_DRAWTBX_CS_FLOWCHART10,			CommandGroup::INSERT );
2046cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" ,	    SID_DRAWTBX_CS_FLOWCHART11,			CommandGroup::INSERT );
2047cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" ,	SID_DRAWTBX_CS_FLOWCHART12,			CommandGroup::INSERT );
2048cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" ,			SID_DRAWTBX_CS_FLOWCHART13,			CommandGroup::INSERT );
2049cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" ,	SID_DRAWTBX_CS_FLOWCHART14,			CommandGroup::INSERT );
2050cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" ,				SID_DRAWTBX_CS_FLOWCHART15,			CommandGroup::INSERT );
2051cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" ,		SID_DRAWTBX_CS_FLOWCHART16,			CommandGroup::INSERT );
2052cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" ,	SID_DRAWTBX_CS_FLOWCHART17,			CommandGroup::INSERT );
2053cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" ,				    SID_DRAWTBX_CS_FLOWCHART18,			CommandGroup::INSERT );
2054cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" ,			SID_DRAWTBX_CS_FLOWCHART19,			CommandGroup::INSERT );
2055cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" ,				SID_DRAWTBX_CS_FLOWCHART20,			CommandGroup::INSERT );
2056cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" ,			SID_DRAWTBX_CS_FLOWCHART21,			CommandGroup::INSERT );
2057cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" ,				SID_DRAWTBX_CS_FLOWCHART22,			CommandGroup::INSERT );
2058cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" ,		SID_DRAWTBX_CS_FLOWCHART23,			CommandGroup::INSERT );
2059cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" ,				SID_DRAWTBX_CS_FLOWCHART24,			CommandGroup::INSERT );
2060cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" ,	SID_DRAWTBX_CS_FLOWCHART25,			CommandGroup::INSERT );
2061cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" ,		SID_DRAWTBX_CS_FLOWCHART26,			CommandGroup::INSERT );
2062cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27,		CommandGroup::INSERT );
2063cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" ,			SID_DRAWTBX_CS_FLOWCHART28,			CommandGroup::INSERT );
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" ,		SID_DRAWTBX_CS_CALLOUT1,			CommandGroup::INSERT );
2066cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" ,	SID_DRAWTBX_CS_CALLOUT2,			CommandGroup::INSERT );
2067cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" ,				SID_DRAWTBX_CS_CALLOUT3,			CommandGroup::INSERT );
2068cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" ,				SID_DRAWTBX_CS_CALLOUT4,			CommandGroup::INSERT );
2069cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" ,				SID_DRAWTBX_CS_CALLOUT5,			CommandGroup::INSERT );
2070cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" ,				SID_DRAWTBX_CS_CALLOUT6,			CommandGroup::INSERT );
2071cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" ,				SID_DRAWTBX_CS_CALLOUT7,			CommandGroup::INSERT );
2072cdf0e10cSrcweir 
2073cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ArrowShapes",				SID_DRAWTBX_CS_ARROW,			CommandGroup::INSERT );
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:FlowChartShapes",   		SID_DRAWTBX_CS_FLOWCHART,		CommandGroup::INSERT );
2076cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CalloutShapes",   		    SID_DRAWTBX_CS_CALLOUT,			CommandGroup::INSERT );
2077cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:StarShapes",   	    	    SID_DRAWTBX_CS_STAR,			CommandGroup::INSERT );
2078cdf0e10cSrcweir 
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir     // keys
2081cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Escape",					SID_ESCAPE,                     CommandGroup::CONTROLS);
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 	// internal one
2084cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO",			SID_REPORTHEADER_WITHOUT_UNDO);
2085cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO",			SID_REPORTFOOTER_WITHOUT_UNDO);
2086cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO",				SID_PAGEHEADER_WITHOUT_UNDO);
2087cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO",				SID_PAGEFOOTER_WITHOUT_UNDO);
2088cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:DBBackgroundColor",				SID_ATTR_CHAR_COLOR_BACKGROUND);
2089cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUPHEADER",				SID_GROUPHEADER);
2090cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO",	SID_GROUPHEADER_WITHOUT_UNDO);
2091cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER",				SID_GROUPFOOTER);
2092cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO",	SID_GROUPFOOTER_WITHOUT_UNDO);
2093cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE",				SID_GROUP_REMOVE);
2094cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND",				SID_GROUP_APPEND);
2095cdf0e10cSrcweir 	implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR",			SID_ADD_CONTROL_PAIR);
2096cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SplitPosition",			        SID_SPLIT_POSITION);
2097cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage",	    SID_PROPERTYBROWSER_LAST_PAGE);
2098cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:Select",	                    SID_SELECT);
2099cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:InsertFunction",				SID_RPT_NEW_FUNCTION);
2100cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:NextMark",				        SID_NEXT_MARK);
2101cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:PrevMark",				        SID_PREV_MARK);
2102cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:TerminateInplaceActivation",    SID_TERMINATE_INPLACEACTIVATION);
2103cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SelectAllLabels",               SID_SELECT_ALL_LABELS);
2104cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:SelectAllEdits",                SID_SELECT_ALL_EDITS);
2105cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:CollapseSection",			SID_COLLAPSE_SECTION);
2106cdf0e10cSrcweir     implDescribeSupportedFeature( ".uno:ExpandSection",				SID_EXPAND_SECTION);
2107cdf0e10cSrcweir }
2108cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_onModifyChanged()2109cdf0e10cSrcweir void OReportController::impl_onModifyChanged()
2110cdf0e10cSrcweir {
2111cdf0e10cSrcweir 	try
2112cdf0e10cSrcweir     {
2113cdf0e10cSrcweir 	    if ( m_xReportDefinition.is() )
2114cdf0e10cSrcweir 		    m_xReportDefinition->setModified( impl_isModified() );
2115cdf0e10cSrcweir         DBSubComponentController::impl_onModifyChanged();
2116cdf0e10cSrcweir     }
2117cdf0e10cSrcweir     catch(uno::Exception)
2118cdf0e10cSrcweir     {
2119cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
2120cdf0e10cSrcweir     }
2121cdf0e10cSrcweir }
2122cdf0e10cSrcweir // -----------------------------------------------------------------------------
onLoadedMenu(const Reference<frame::XLayoutManager> & _xLayoutManager)2123cdf0e10cSrcweir void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager)
2124cdf0e10cSrcweir {
2125cdf0e10cSrcweir 	if ( _xLayoutManager.is() )
2126cdf0e10cSrcweir 	{
2127cdf0e10cSrcweir         static const ::rtl::OUString s_sMenu[] = {
2128cdf0e10cSrcweir 		     ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/statusbar/statusbar"))
2129cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/reportcontrols"))
2130cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/drawbar"))
2131cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/Formatting"))
2132cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/alignmentbar"))
2133cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionalignmentbar"))
2134cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/resizebar"))
2135cdf0e10cSrcweir             ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionshrinkbar"))
2136cdf0e10cSrcweir         };
2137cdf0e10cSrcweir         for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i)
2138cdf0e10cSrcweir         {
2139cdf0e10cSrcweir             _xLayoutManager->createElement( s_sMenu[i] );
2140cdf0e10cSrcweir 		    _xLayoutManager->requestElement( s_sMenu[i] );
2141cdf0e10cSrcweir         }
2142cdf0e10cSrcweir 	} // if ( _xLayoutManager.is() )
2143cdf0e10cSrcweir }
2144cdf0e10cSrcweir // -----------------------------------------------------------------------------
notifyGroupSections(const ContainerEvent & _rEvent,bool _bShow)2145cdf0e10cSrcweir void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow)
2146cdf0e10cSrcweir {
2147cdf0e10cSrcweir     uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY);
2148cdf0e10cSrcweir 	if ( xGroup.is() )
2149cdf0e10cSrcweir 	{
2150cdf0e10cSrcweir         ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
2151cdf0e10cSrcweir 	    ::osl::MutexGuard aGuard( getMutex() );
2152cdf0e10cSrcweir         sal_Int32 nGroupPos = 0;
2153cdf0e10cSrcweir 		_rEvent.Accessor >>= nGroupPos;
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir         if ( _bShow )
2156cdf0e10cSrcweir         {
2157cdf0e10cSrcweir 		    xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2158cdf0e10cSrcweir 		    xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2159cdf0e10cSrcweir         }
2160cdf0e10cSrcweir         else
2161cdf0e10cSrcweir         {
2162cdf0e10cSrcweir             xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2163cdf0e10cSrcweir 		    xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2164cdf0e10cSrcweir         }
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir 	    if ( xGroup->getHeaderOn() )
2167cdf0e10cSrcweir 	    {
2168cdf0e10cSrcweir 		    groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow);
2169cdf0e10cSrcweir             if (_bShow)
2170cdf0e10cSrcweir             {
2171cdf0e10cSrcweir                 m_pReportControllerObserver->AddSection(xGroup->getHeader());
2172cdf0e10cSrcweir             }
2173cdf0e10cSrcweir             else
2174cdf0e10cSrcweir             {
2175cdf0e10cSrcweir                 m_pReportControllerObserver->RemoveSection(xGroup->getHeader());
2176cdf0e10cSrcweir             }
2177cdf0e10cSrcweir 	    }
2178cdf0e10cSrcweir 	    if ( xGroup->getFooterOn() )
2179cdf0e10cSrcweir 	    {
2180cdf0e10cSrcweir 		    groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow);
2181cdf0e10cSrcweir             if (_bShow)
2182cdf0e10cSrcweir             {
2183cdf0e10cSrcweir                 m_pReportControllerObserver->AddSection(xGroup->getFooter());
2184cdf0e10cSrcweir             }
2185cdf0e10cSrcweir             else
2186cdf0e10cSrcweir             {
2187cdf0e10cSrcweir                 m_pReportControllerObserver->RemoveSection(xGroup->getFooter());
2188cdf0e10cSrcweir             }
2189cdf0e10cSrcweir 	    }
2190cdf0e10cSrcweir     }
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir // -----------------------------------------------------------------------------
2193cdf0e10cSrcweir // ::container::XContainerListener
elementInserted(const ContainerEvent & _rEvent)2194cdf0e10cSrcweir void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
2195cdf0e10cSrcweir {
2196cdf0e10cSrcweir 	notifyGroupSections(_rEvent,true);
2197cdf0e10cSrcweir }
2198cdf0e10cSrcweir // -----------------------------------------------------------------------------
elementRemoved(const ContainerEvent & _rEvent)2199cdf0e10cSrcweir void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
2200cdf0e10cSrcweir {
2201cdf0e10cSrcweir 	notifyGroupSections(_rEvent,false);
2202cdf0e10cSrcweir }
2203cdf0e10cSrcweir // -----------------------------------------------------------------------------
elementReplaced(const ContainerEvent &)2204cdf0e10cSrcweir void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ ) throw(RuntimeException)
2205cdf0e10cSrcweir {
2206cdf0e10cSrcweir 	::vos::OGuard aSolarGuard(Application::GetSolarMutex());
2207cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
2208cdf0e10cSrcweir 	OSL_ENSURE(0,"Not yet implemented!");
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir // -----------------------------------------------------------------------------
propertyChange(const beans::PropertyChangeEvent & evt)2211cdf0e10cSrcweir void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException)
2212cdf0e10cSrcweir {
2213cdf0e10cSrcweir 	::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2214cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
2215cdf0e10cSrcweir 	try
2216cdf0e10cSrcweir 	{
2217cdf0e10cSrcweir 		sal_Bool bShow = sal_False;
2218cdf0e10cSrcweir 		evt.NewValue >>= bShow;
2219cdf0e10cSrcweir 		if ( evt.Source == m_xReportDefinition )
2220cdf0e10cSrcweir 		{
2221cdf0e10cSrcweir 			if ( evt.PropertyName.equals( PROPERTY_REPORTHEADERON ) )
2222cdf0e10cSrcweir 			{
2223cdf0e10cSrcweir                 const sal_uInt16 nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0;
2224cdf0e10cSrcweir 				if ( bShow )
2225cdf0e10cSrcweir                 {
2226cdf0e10cSrcweir                     getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition);
2227cdf0e10cSrcweir                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader());
2228cdf0e10cSrcweir                 }
2229cdf0e10cSrcweir 				else
2230cdf0e10cSrcweir                 {
2231cdf0e10cSrcweir                     getDesignView()->removeSection(nPosition);
2232cdf0e10cSrcweir     			}
2233cdf0e10cSrcweir             }
2234cdf0e10cSrcweir 			else if ( evt.PropertyName.equals( PROPERTY_REPORTFOOTERON ) )
2235cdf0e10cSrcweir 			{
2236cdf0e10cSrcweir                 sal_uInt16 nPosition = getDesignView()->getSectionCount();
2237cdf0e10cSrcweir 				if ( m_xReportDefinition->getPageFooterOn() )
2238cdf0e10cSrcweir 					--nPosition;
2239cdf0e10cSrcweir 				if ( bShow )
2240cdf0e10cSrcweir                 {
2241cdf0e10cSrcweir                     getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition);
2242cdf0e10cSrcweir                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter());
2243cdf0e10cSrcweir                 }
2244cdf0e10cSrcweir                 else
2245cdf0e10cSrcweir                 {
2246cdf0e10cSrcweir                     getDesignView()->removeSection(nPosition - 1);
2247cdf0e10cSrcweir     			}
2248cdf0e10cSrcweir             }
2249cdf0e10cSrcweir 			else if ( evt.PropertyName.equals( PROPERTY_PAGEHEADERON ) )
2250cdf0e10cSrcweir 			{
2251cdf0e10cSrcweir 				if ( bShow )
2252cdf0e10cSrcweir                 {
2253cdf0e10cSrcweir                     getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0);
2254cdf0e10cSrcweir                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader());
2255cdf0e10cSrcweir                 }
2256cdf0e10cSrcweir 				else
2257cdf0e10cSrcweir                 {
2258cdf0e10cSrcweir                     getDesignView()->removeSection(sal_uInt16(0));
2259cdf0e10cSrcweir                 }
2260cdf0e10cSrcweir 			}
2261cdf0e10cSrcweir 			else if ( evt.PropertyName.equals( PROPERTY_PAGEFOOTERON ) )
2262cdf0e10cSrcweir 			{
2263cdf0e10cSrcweir                 if ( bShow )
2264cdf0e10cSrcweir                 {
2265cdf0e10cSrcweir                     getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
2266cdf0e10cSrcweir                     m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter());
2267cdf0e10cSrcweir                 }
2268cdf0e10cSrcweir 				else
2269cdf0e10cSrcweir                 {
2270cdf0e10cSrcweir                     getDesignView()->removeSection(getDesignView()->getSectionCount() - 1);
2271cdf0e10cSrcweir                 }
2272cdf0e10cSrcweir 			}
2273cdf0e10cSrcweir             else if (   evt.PropertyName.equals( PROPERTY_COMMAND )
2274cdf0e10cSrcweir                     ||  evt.PropertyName.equals( PROPERTY_COMMANDTYPE )
2275cdf0e10cSrcweir                     ||  evt.PropertyName.equals( PROPERTY_ESCAPEPROCESSING )
2276cdf0e10cSrcweir                     ||  evt.PropertyName.equals( PROPERTY_FILTER )
2277cdf0e10cSrcweir                     )
2278cdf0e10cSrcweir 			{
2279cdf0e10cSrcweir                 m_xColumns.clear();
2280cdf0e10cSrcweir                 m_xHoldAlive.clear();
2281cdf0e10cSrcweir                 InvalidateFeature(SID_FM_ADD_FIELD);
2282cdf0e10cSrcweir                 if ( !getDesignView()->isAddFieldVisible() && isUiVisible() )
2283cdf0e10cSrcweir                     getDesignView()->toggleAddField();
2284cdf0e10cSrcweir             }
2285cdf0e10cSrcweir             /// TODO: check what we need to notify here TitleHelper
2286cdf0e10cSrcweir             /*else if (   evt.PropertyName.equals( PROPERTY_CAPTION ) )
2287cdf0e10cSrcweir                 updateTitle();*/
2288cdf0e10cSrcweir 		} // if ( evt.Source == m_xReportDefinition )
2289cdf0e10cSrcweir 		else
2290cdf0e10cSrcweir 		{
2291cdf0e10cSrcweir 			uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY);
2292cdf0e10cSrcweir 			if ( xGroup.is() )
2293cdf0e10cSrcweir 			{
2294cdf0e10cSrcweir 				sal_Int32 nGroupPos = getGroupPosition(xGroup);
2295cdf0e10cSrcweir 
2296cdf0e10cSrcweir 				groupChange(xGroup,evt.PropertyName,nGroupPos,bShow);
2297cdf0e10cSrcweir 			}
2298cdf0e10cSrcweir 		}
2299cdf0e10cSrcweir 	}
2300cdf0e10cSrcweir     catch(const uno::Exception&)
2301cdf0e10cSrcweir 	{
2302cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
2303cdf0e10cSrcweir 	}
2304cdf0e10cSrcweir }
2305cdf0e10cSrcweir 
2306cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing(const lang::EventObject & Source)2307cdf0e10cSrcweir void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) throw(uno::RuntimeException)
2308cdf0e10cSrcweir {
2309cdf0e10cSrcweir     // simply disambiguate
2310cdf0e10cSrcweir     OReportController_BASE::disposing(Source);
2311cdf0e10cSrcweir }
2312cdf0e10cSrcweir 
2313cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getNonVisbleGroupsBefore(const uno::Reference<report::XGroups> & _xGroups,sal_Int32 _nGroupPos,::std::mem_fun_t<sal_Bool,OGroupHelper> & _pGroupMemberFunction)2314cdf0e10cSrcweir sal_uInt16 lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups
2315cdf0e10cSrcweir 						  ,sal_Int32 _nGroupPos
2316cdf0e10cSrcweir 						  ,::std::mem_fun_t<sal_Bool,OGroupHelper>&_pGroupMemberFunction)
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir 	uno::Reference< report::XGroup> xGroup;
2319cdf0e10cSrcweir 	sal_uInt16 nNonVisibleGroups = 0;
2320cdf0e10cSrcweir 	sal_Int32 nCount = _xGroups->getCount();
2321cdf0e10cSrcweir 	for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i)
2322cdf0e10cSrcweir 	{
2323cdf0e10cSrcweir 		xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY);
2324cdf0e10cSrcweir 		OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF");
2325cdf0e10cSrcweir 		OGroupHelper aGroupHelper(xGroup);
2326cdf0e10cSrcweir 		if ( !_pGroupMemberFunction(&aGroupHelper) )
2327cdf0e10cSrcweir 			++nNonVisibleGroups;
2328cdf0e10cSrcweir 	}
2329cdf0e10cSrcweir 	return nNonVisibleGroups;
2330cdf0e10cSrcweir }
2331cdf0e10cSrcweir // -----------------------------------------------------------------------------
groupChange(const uno::Reference<report::XGroup> & _xGroup,const::rtl::OUString & _sPropName,sal_Int32 _nGroupPos,bool _bShow)2332cdf0e10cSrcweir void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const ::rtl::OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow)
2333cdf0e10cSrcweir {
2334cdf0e10cSrcweir 	//adjustSectionName(_xGroup,_nGroupPos);
2335cdf0e10cSrcweir 	::std::mem_fun_t<sal_Bool,OGroupHelper> pMemFun = ::std::mem_fun(&OGroupHelper::getHeaderOn);
2336cdf0e10cSrcweir 	::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader);
2337cdf0e10cSrcweir 	::rtl::OUString sColor(DBGROUPHEADER);
2338cdf0e10cSrcweir 	sal_uInt16 nPosition = 0;
2339cdf0e10cSrcweir 	bool bHandle = false;
2340cdf0e10cSrcweir 	if ( _sPropName.equals( PROPERTY_HEADERON ) )
2341cdf0e10cSrcweir 	{
2342cdf0e10cSrcweir 		nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0);
2343cdf0e10cSrcweir 		nPosition += (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2344cdf0e10cSrcweir 		bHandle = true;
2345cdf0e10cSrcweir 	}
2346cdf0e10cSrcweir 	else if ( _sPropName.equals( PROPERTY_FOOTERON ) )
2347cdf0e10cSrcweir 	{
2348cdf0e10cSrcweir 		pMemFun = ::std::mem_fun(&OGroupHelper::getFooterOn);
2349cdf0e10cSrcweir 		pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter);
2350cdf0e10cSrcweir 		nPosition = getDesignView()->getSectionCount();
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir         if ( m_xReportDefinition->getPageFooterOn() )
2353cdf0e10cSrcweir 			--nPosition;
2354cdf0e10cSrcweir 		if ( m_xReportDefinition->getReportFooterOn() )
2355cdf0e10cSrcweir 			--nPosition;
2356cdf0e10cSrcweir 		sColor = DBGROUPFOOTER;
2357cdf0e10cSrcweir 		nPosition -= (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2358cdf0e10cSrcweir 		if ( !_bShow )
2359cdf0e10cSrcweir 			--nPosition;
2360cdf0e10cSrcweir 		bHandle = true;
2361cdf0e10cSrcweir 	}
2362cdf0e10cSrcweir 	if ( bHandle )
2363cdf0e10cSrcweir 	{
2364cdf0e10cSrcweir 		if ( _bShow )
2365cdf0e10cSrcweir 		{
2366cdf0e10cSrcweir 			OGroupHelper aGroupHelper(_xGroup);
2367cdf0e10cSrcweir 			getDesignView()->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition);
2368cdf0e10cSrcweir 		}
2369cdf0e10cSrcweir 		else
2370cdf0e10cSrcweir         {
2371cdf0e10cSrcweir             getDesignView()->removeSection(nPosition);
2372cdf0e10cSrcweir         }
2373cdf0e10cSrcweir 	}
2374cdf0e10cSrcweir }
2375cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OReportController,OnClipboardChanged,void *,EMPTYARG)2376cdf0e10cSrcweir IMPL_LINK( OReportController, OnClipboardChanged, void*, EMPTYARG )
2377cdf0e10cSrcweir {
2378cdf0e10cSrcweir 	return OnInvalidateClipboard( NULL );
2379cdf0e10cSrcweir }
2380cdf0e10cSrcweir //------------------------------------------------------------------------------
IMPL_LINK(OReportController,OnInvalidateClipboard,void *,EMPTYARG)2381cdf0e10cSrcweir IMPL_LINK(OReportController, OnInvalidateClipboard, void*, EMPTYARG)
2382cdf0e10cSrcweir {
2383cdf0e10cSrcweir 	InvalidateFeature(SID_CUT);
2384cdf0e10cSrcweir 	InvalidateFeature(SID_COPY);
2385cdf0e10cSrcweir 	InvalidateFeature(SID_PASTE);
2386cdf0e10cSrcweir 	return 0L;
2387cdf0e10cSrcweir }
2388cdf0e10cSrcweir // -----------------------------------------------------------------------------
openPageDialog(const uno::Reference<report::XSection> & _xSection)2389cdf0e10cSrcweir void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection)
2390cdf0e10cSrcweir {
2391cdf0e10cSrcweir 	if ( !m_xReportDefinition.is() )
2392cdf0e10cSrcweir 		return;
2393cdf0e10cSrcweir 	// ------------
2394cdf0e10cSrcweir 	// UNO->ItemSet
2395cdf0e10cSrcweir 	static SfxItemInfo aItemInfos[] =
2396cdf0e10cSrcweir 	{
2397cdf0e10cSrcweir 		{ SID_ATTR_LRSPACE,		SFX_ITEM_POOLABLE },
2398cdf0e10cSrcweir 		{ SID_ATTR_ULSPACE,		SFX_ITEM_POOLABLE },
2399cdf0e10cSrcweir 		{ SID_ATTR_PAGE,		SFX_ITEM_POOLABLE },
2400cdf0e10cSrcweir 		{ SID_ATTR_PAGE_SIZE,	SFX_ITEM_POOLABLE },
2401cdf0e10cSrcweir 		{ SID_ENUM_PAGE_MODE,	SFX_ITEM_POOLABLE },
2402cdf0e10cSrcweir 		{ SID_PAPER_START,		SFX_ITEM_POOLABLE },
2403cdf0e10cSrcweir 		{ SID_PAPER_END,		SFX_ITEM_POOLABLE },
2404cdf0e10cSrcweir 		{ SID_ATTR_BRUSH,		SFX_ITEM_POOLABLE },
2405cdf0e10cSrcweir 		{ SID_FLAG_TYPE,		SFX_ITEM_POOLABLE },
2406cdf0e10cSrcweir 		{ SID_ATTR_METRIC,		SFX_ITEM_POOLABLE }
2407cdf0e10cSrcweir 	};
2408cdf0e10cSrcweir 
2409cdf0e10cSrcweir 	MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
2410cdf0e10cSrcweir     FieldUnit eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
2411cdf0e10cSrcweir 	SfxPoolItem* pDefaults[] =
2412cdf0e10cSrcweir 	{
2413cdf0e10cSrcweir 		new SvxLRSpaceItem(RPTUI_ID_LRSPACE),
2414cdf0e10cSrcweir 		new SvxULSpaceItem(RPTUI_ID_ULSPACE),
2415cdf0e10cSrcweir 		new SvxPageItem(RPTUI_ID_PAGE),
2416cdf0e10cSrcweir 		new SvxSizeItem(RPTUI_ID_SIZE),
2417cdf0e10cSrcweir 		new SfxAllEnumItem(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD),
2418cdf0e10cSrcweir 		new SfxAllEnumItem(RPTUI_ID_START,PAPER_A4),
2419cdf0e10cSrcweir 		new SfxAllEnumItem(RPTUI_ID_END,PAPER_E),
2420cdf0e10cSrcweir 		new SvxBrushItem(ITEMID_BRUSH),
2421cdf0e10cSrcweir 		new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<sal_uInt16>(eUserMetric))
2422cdf0e10cSrcweir 	};
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir 	static sal_uInt16 pRanges[] =
2425cdf0e10cSrcweir 	{
2426cdf0e10cSrcweir 		RPTUI_ID_LRSPACE,RPTUI_ID_BRUSH,
2427cdf0e10cSrcweir 		SID_ATTR_METRIC,SID_ATTR_METRIC,
2428cdf0e10cSrcweir         0
2429cdf0e10cSrcweir 	};
2430cdf0e10cSrcweir 	SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ReportPageProperties"), RPTUI_ID_LRSPACE,RPTUI_ID_METRIC, aItemInfos, pDefaults) );
2431cdf0e10cSrcweir 	pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );	// ripped, don't understand why
2432cdf0e10cSrcweir 	pPool->FreezeIdRanges();						// the same
2433cdf0e10cSrcweir 
2434cdf0e10cSrcweir 	try
2435cdf0e10cSrcweir 	{
2436cdf0e10cSrcweir 		::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
2437cdf0e10cSrcweir 		// fill it
2438cdf0e10cSrcweir 		if ( _xSection.is() )
2439cdf0e10cSrcweir 			pDescriptor->Put(SvxBrushItem(::Color(_xSection->getBackColor()),ITEMID_BRUSH));
2440cdf0e10cSrcweir 		else
2441cdf0e10cSrcweir 		{
2442cdf0e10cSrcweir             pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
2443cdf0e10cSrcweir 			pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
2444cdf0e10cSrcweir                                             ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
2445cdf0e10cSrcweir 			pDescriptor->Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
2446cdf0e10cSrcweir                                             ,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
2447cdf0e10cSrcweir 			pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric)));
2448cdf0e10cSrcweir 
2449cdf0e10cSrcweir             uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition));
2450cdf0e10cSrcweir             if ( xPageStyle.is() )
2451cdf0e10cSrcweir             {
2452cdf0e10cSrcweir                 SvxPageItem aPageItem(RPTUI_ID_PAGE);
2453cdf0e10cSrcweir                 aPageItem.SetDescName(xPageStyle->getName());
2454cdf0e10cSrcweir                 uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW);
2455cdf0e10cSrcweir                 aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT);
2456cdf0e10cSrcweir 	            aPageItem.SetLandscape(getStyleProperty<sal_Bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE));
2457cdf0e10cSrcweir 	            aPageItem.SetNumType((SvxNumType)getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE));
2458cdf0e10cSrcweir                 pDescriptor->Put(aPageItem);
2459cdf0e10cSrcweir                 pDescriptor->Put(SvxBrushItem(::Color(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH));
2460cdf0e10cSrcweir             }
2461cdf0e10cSrcweir 		}
2462cdf0e10cSrcweir 
2463cdf0e10cSrcweir 		{	// want the dialog to be destroyed before our set
2464cdf0e10cSrcweir 			ORptPageDialog aDlg(getView(), pDescriptor.get(),_xSection.is() ? RID_PAGEDIALOG_BACKGROUND : RID_PAGEDIALOG_PAGE);
2465cdf0e10cSrcweir 			if (RET_OK == aDlg.Execute())
2466cdf0e10cSrcweir 			{
2467cdf0e10cSrcweir 				// ------------
2468cdf0e10cSrcweir 				// ItemSet->UNO
2469cdf0e10cSrcweir 				// UNO-properties
2470cdf0e10cSrcweir 				const SfxItemSet* pSet = aDlg.GetOutputItemSet();
2471cdf0e10cSrcweir 				if ( _xSection.is() )
2472cdf0e10cSrcweir 				{
2473cdf0e10cSrcweir 					const SfxPoolItem* pItem;
2474cdf0e10cSrcweir 					if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem))
2475cdf0e10cSrcweir 						_xSection->setBackColor(static_cast<const SvxBrushItem*>(pItem)->GetColor().GetColor());
2476cdf0e10cSrcweir 				}
2477cdf0e10cSrcweir 				else
2478cdf0e10cSrcweir 				{
2479cdf0e10cSrcweir                     uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW);
2480cdf0e10cSrcweir                     const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEPAGE));
2481cdf0e10cSrcweir                     UndoContext aUndoContext( getUndoManager(), sUndoAction );
2482cdf0e10cSrcweir 					const SfxPoolItem* pItem = NULL;
2483cdf0e10cSrcweir 					if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_SIZE,sal_True,&pItem))
2484cdf0e10cSrcweir                     {
2485cdf0e10cSrcweir                         const Size aPaperSize = static_cast<const SvxSizeItem*>(pItem)->GetSize();
2486cdf0e10cSrcweir                         uno::Any aValue;
2487cdf0e10cSrcweir                         static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue,MID_SIZE_SIZE);
2488cdf0e10cSrcweir 						xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue);
2489cdf0e10cSrcweir                         resetZoomType();
2490cdf0e10cSrcweir                     }
2491cdf0e10cSrcweir 
2492cdf0e10cSrcweir 					if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_LRSPACE,sal_True,&pItem))
2493cdf0e10cSrcweir 					{
2494cdf0e10cSrcweir                         Any aValue;
2495cdf0e10cSrcweir                         static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_L_MARGIN);
2496cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_LEFTMARGIN,aValue);
2497cdf0e10cSrcweir                         static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_R_MARGIN);
2498cdf0e10cSrcweir 						xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,aValue);
2499cdf0e10cSrcweir 					}
2500cdf0e10cSrcweir 					if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_ULSPACE,sal_True,&pItem))
2501cdf0e10cSrcweir 					{
2502cdf0e10cSrcweir 						xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()));
2503cdf0e10cSrcweir 						xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower()));
2504cdf0e10cSrcweir 					}
2505cdf0e10cSrcweir                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_PAGE,sal_True,&pItem))
2506cdf0e10cSrcweir 					{
2507cdf0e10cSrcweir                         const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem);
2508cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(static_cast<sal_Bool>(pPageItem->IsLandscape())));
2509cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType())));
2510cdf0e10cSrcweir                         uno::Any aValue;
2511cdf0e10cSrcweir                         pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT);
2512cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue);
2513cdf0e10cSrcweir                         resetZoomType();
2514cdf0e10cSrcweir                     }
2515cdf0e10cSrcweir                     if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem))
2516cdf0e10cSrcweir                     {
2517cdf0e10cSrcweir                         ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
2518cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT));
2519cdf0e10cSrcweir                         xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor.GetColor()));
2520cdf0e10cSrcweir                     }
2521cdf0e10cSrcweir 				}
2522cdf0e10cSrcweir 			}
2523cdf0e10cSrcweir 		}
2524cdf0e10cSrcweir 	}
2525cdf0e10cSrcweir 	catch(Exception&)
2526cdf0e10cSrcweir 	{
2527cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
2528cdf0e10cSrcweir 	}
2529cdf0e10cSrcweir 	SfxItemPool::Free(pPool);
2530cdf0e10cSrcweir 
2531cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
2532cdf0e10cSrcweir 		delete pDefaults[i];
2533cdf0e10cSrcweir 
2534cdf0e10cSrcweir }
2535cdf0e10cSrcweir 
2536cdf0e10cSrcweir // -----------------------------------------------------------------------------
attachModel(const uno::Reference<frame::XModel> & xModel)2537cdf0e10cSrcweir sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException )
2538cdf0e10cSrcweir {
2539cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
2540cdf0e10cSrcweir 
2541cdf0e10cSrcweir     uno::Reference< report::XReportDefinition > xReportDefinition( xModel, UNO_QUERY );
2542cdf0e10cSrcweir     if ( !xReportDefinition.is() )
2543cdf0e10cSrcweir         return sal_False;
2544cdf0e10cSrcweir 
2545cdf0e10cSrcweir     uno::Reference< document::XUndoManagerSupplier > xTestSuppUndo( xModel, UNO_QUERY );
2546cdf0e10cSrcweir     if ( !xTestSuppUndo.is() )
2547cdf0e10cSrcweir         return sal_False;
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir 	m_xReportDefinition = xReportDefinition;
2550cdf0e10cSrcweir     return sal_True;
2551cdf0e10cSrcweir }
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir // -----------------------------------------------------------------------------
openSortingAndGroupingDialog()2554cdf0e10cSrcweir void OReportController::openSortingAndGroupingDialog()
2555cdf0e10cSrcweir {
2556cdf0e10cSrcweir     if ( !m_xReportDefinition.is() )
2557cdf0e10cSrcweir         return;
2558cdf0e10cSrcweir 	if ( !m_pGroupsFloater )
2559cdf0e10cSrcweir 	{
2560cdf0e10cSrcweir 		m_pGroupsFloater = new OGroupsSortingDialog(getView(),!isEditable(),this);
2561cdf0e10cSrcweir         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) );
2562cdf0e10cSrcweir         if ( aDlgOpt.Exists() )
2563cdf0e10cSrcweir             m_pGroupsFloater->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
2564cdf0e10cSrcweir 		m_pGroupsFloater->AddEventListener(LINK(this,OReportController,EventLstHdl));
2565cdf0e10cSrcweir 	}
2566cdf0e10cSrcweir 	else if ( isUiVisible() )
2567cdf0e10cSrcweir 		m_pGroupsFloater->Show(!m_pGroupsFloater->IsVisible());
2568cdf0e10cSrcweir }
2569cdf0e10cSrcweir // -----------------------------------------------------------------------------
getGroupPosition(const uno::Reference<report::XGroup> & _xGroup)2570cdf0e10cSrcweir sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup)
2571cdf0e10cSrcweir {
2572cdf0e10cSrcweir 	return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),_xGroup);
2573cdf0e10cSrcweir }
2574cdf0e10cSrcweir // -----------------------------------------------------------------------------
2575cdf0e10cSrcweir // -----------------------------------------------------------------------------
IMPL_LINK(OReportController,EventLstHdl,VclWindowEvent *,_pEvent)2576cdf0e10cSrcweir IMPL_LINK( OReportController, EventLstHdl, VclWindowEvent*, _pEvent )
2577cdf0e10cSrcweir {
2578cdf0e10cSrcweir 	if ( _pEvent && _pEvent->GetId() == VCLEVENT_WINDOW_CLOSE )
2579cdf0e10cSrcweir 	{
2580cdf0e10cSrcweir 		InvalidateFeature(SID_SORTINGANDGROUPING);
2581cdf0e10cSrcweir         InvalidateFeature(SID_FM_ADD_FIELD);
2582cdf0e10cSrcweir         InvalidateFeature(SID_RPT_SHOWREPORTEXPLORER);
2583cdf0e10cSrcweir 	}
2584cdf0e10cSrcweir 	return 1L;
2585cdf0e10cSrcweir }
2586cdf0e10cSrcweir // -----------------------------------------------------------------------------
Notify(SfxBroadcaster &,SfxHint const & _rHint)2587cdf0e10cSrcweir void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint)
2588cdf0e10cSrcweir {
2589cdf0e10cSrcweir     if (_rHint.ISA(DlgEdHint)
2590cdf0e10cSrcweir         && (static_cast< DlgEdHint const & >(_rHint).GetKind()
2591cdf0e10cSrcweir             == RPTUI_HINT_SELECTIONCHANGED))
2592cdf0e10cSrcweir     {
2593cdf0e10cSrcweir         const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount();
2594cdf0e10cSrcweir         if ( m_nSelectionCount != nSelectionCount )
2595cdf0e10cSrcweir         {
2596cdf0e10cSrcweir             m_nSelectionCount = nSelectionCount;
2597cdf0e10cSrcweir 		    InvalidateAll();
2598cdf0e10cSrcweir         }
2599cdf0e10cSrcweir         lang::EventObject aEvent(*this);
2600cdf0e10cSrcweir         m_aSelectionListeners.forEach<view::XSelectionChangeListener>(
2601cdf0e10cSrcweir 			::boost::bind(&view::XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
2602cdf0e10cSrcweir 
2603cdf0e10cSrcweir 	}
2604cdf0e10cSrcweir }
2605cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeMethodWithUndo(sal_uInt16 _nUndoStrId,const::std::mem_fun_t<void,ODesignView> & _pMemfun)2606cdf0e10cSrcweir void OReportController::executeMethodWithUndo(sal_uInt16 _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun)
2607cdf0e10cSrcweir {
2608cdf0e10cSrcweir     const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2609cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), sUndoAction );
2610cdf0e10cSrcweir     _pMemfun( getDesignView() );
2611cdf0e10cSrcweir 	InvalidateFeature( SID_SAVEDOC );
2612cdf0e10cSrcweir 	InvalidateFeature( SID_UNDO );
2613cdf0e10cSrcweir }
2614cdf0e10cSrcweir // -----------------------------------------------------------------------------
alignControlsWithUndo(sal_uInt16 _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection)2615cdf0e10cSrcweir void OReportController::alignControlsWithUndo(sal_uInt16 _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection)
2616cdf0e10cSrcweir {
2617cdf0e10cSrcweir     const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2618cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), sUndoAction );
2619cdf0e10cSrcweir     getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection);
2620cdf0e10cSrcweir 	InvalidateFeature( SID_SAVEDOC );
2621cdf0e10cSrcweir 	InvalidateFeature( SID_UNDO );
2622cdf0e10cSrcweir }
2623cdf0e10cSrcweir // -----------------------------------------------------------------------------
shrinkSectionBottom(uno::Reference<report::XSection> _xSection)2624cdf0e10cSrcweir void OReportController::shrinkSectionBottom(uno::Reference<report::XSection> _xSection)
2625cdf0e10cSrcweir {
2626cdf0e10cSrcweir     const sal_Int32 nElements = _xSection->getCount();
2627cdf0e10cSrcweir     if (nElements == 0)
2628cdf0e10cSrcweir     {
2629cdf0e10cSrcweir         // there are no elements
2630cdf0e10cSrcweir         return;
2631cdf0e10cSrcweir     }
2632cdf0e10cSrcweir     const sal_Int32 nSectionHeight = _xSection->getHeight();
2633cdf0e10cSrcweir     // sal_Int32 nMinPositionY = nSectionHeight;
2634cdf0e10cSrcweir     sal_Int32 nMaxPositionY = 0;
2635cdf0e10cSrcweir     uno::Reference< report::XReportComponent> xReportComponent;
2636cdf0e10cSrcweir 
2637cdf0e10cSrcweir     // for every component get it's Y-position and compare it to the current Y-position
2638cdf0e10cSrcweir     for (int i=0;i<nElements;i++)
2639cdf0e10cSrcweir     {
2640cdf0e10cSrcweir         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2641cdf0e10cSrcweir         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2642cdf0e10cSrcweir         const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2643cdf0e10cSrcweir         const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2644cdf0e10cSrcweir         // nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2645cdf0e10cSrcweir         nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2646cdf0e10cSrcweir     }
2647cdf0e10cSrcweir     // now we know the minimal Y-Position and maximal Y-Position
2648cdf0e10cSrcweir 
2649cdf0e10cSrcweir     if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning
2650cdf0e10cSrcweir     {
2651cdf0e10cSrcweir         // the lowest position is already 0
2652cdf0e10cSrcweir         return;
2653cdf0e10cSrcweir     }
2654cdf0e10cSrcweir     _xSection->setHeight(nMaxPositionY);
2655cdf0e10cSrcweir }
2656cdf0e10cSrcweir 
shrinkSectionTop(uno::Reference<report::XSection> _xSection)2657cdf0e10cSrcweir void OReportController::shrinkSectionTop(uno::Reference<report::XSection> _xSection)
2658cdf0e10cSrcweir {
2659cdf0e10cSrcweir     const sal_Int32 nElements = _xSection->getCount();
2660cdf0e10cSrcweir     if (nElements == 0)
2661cdf0e10cSrcweir     {
2662cdf0e10cSrcweir         // there are no elements
2663cdf0e10cSrcweir         return;
2664cdf0e10cSrcweir     }
2665cdf0e10cSrcweir 
2666cdf0e10cSrcweir     const sal_Int32 nSectionHeight = _xSection->getHeight();
2667cdf0e10cSrcweir     sal_Int32 nMinPositionY = nSectionHeight;
2668cdf0e10cSrcweir     // sal_Int32 nMaxPositionY = 0;
2669cdf0e10cSrcweir     uno::Reference< report::XReportComponent> xReportComponent;
2670cdf0e10cSrcweir 
2671cdf0e10cSrcweir     // for every component get it's Y-position and compare it to the current Y-position
2672cdf0e10cSrcweir     for (int i=0;i<nElements;i++)
2673cdf0e10cSrcweir     {
2674cdf0e10cSrcweir         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2675cdf0e10cSrcweir         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2676cdf0e10cSrcweir         // const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2677cdf0e10cSrcweir         // const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2678cdf0e10cSrcweir         nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2679cdf0e10cSrcweir         // nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2680cdf0e10cSrcweir     }
2681cdf0e10cSrcweir     // now we know the minimal Y-Position and maximal Y-Position
2682cdf0e10cSrcweir     if (nMinPositionY == 0)
2683cdf0e10cSrcweir     {
2684cdf0e10cSrcweir         // the lowest position is already 0
2685cdf0e10cSrcweir         return;
2686cdf0e10cSrcweir     }
2687cdf0e10cSrcweir     for (int i=0;i<nElements;i++)
2688cdf0e10cSrcweir     {
2689cdf0e10cSrcweir         xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2690cdf0e10cSrcweir         const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2691cdf0e10cSrcweir         const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY;
2692cdf0e10cSrcweir         xReportComponent->setPositionY(nNewPositionY);
2693cdf0e10cSrcweir     }
2694cdf0e10cSrcweir     const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY;
2695cdf0e10cSrcweir     _xSection->setHeight(nNewSectionHeight);
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir 
shrinkSection(sal_uInt16 _nUndoStrId,uno::Reference<report::XSection> _xSection,sal_Int32 _nSid)2698cdf0e10cSrcweir void OReportController::shrinkSection(sal_uInt16 _nUndoStrId, uno::Reference<report::XSection> _xSection, sal_Int32 _nSid)
2699cdf0e10cSrcweir {
2700cdf0e10cSrcweir 	if ( _xSection.is() )
2701cdf0e10cSrcweir     {
2702cdf0e10cSrcweir         const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2703cdf0e10cSrcweir         UndoContext aUndoContext( getUndoManager(), sUndoAction );
2704cdf0e10cSrcweir 
2705cdf0e10cSrcweir         if (_nSid == SID_SECTION_SHRINK)
2706cdf0e10cSrcweir         {
2707cdf0e10cSrcweir             shrinkSectionTop(_xSection);
2708cdf0e10cSrcweir             shrinkSectionBottom(_xSection);
2709cdf0e10cSrcweir         }
2710cdf0e10cSrcweir         else if (_nSid == SID_SECTION_SHRINK_TOP)
2711cdf0e10cSrcweir         {
2712cdf0e10cSrcweir             shrinkSectionTop(_xSection);
2713cdf0e10cSrcweir         }
2714cdf0e10cSrcweir         else if (_nSid == SID_SECTION_SHRINK_BOTTOM)
2715cdf0e10cSrcweir         {
2716cdf0e10cSrcweir             shrinkSectionBottom(_xSection);
2717cdf0e10cSrcweir         }
2718cdf0e10cSrcweir     }
2719cdf0e10cSrcweir 
2720cdf0e10cSrcweir     InvalidateFeature( SID_SAVEDOC );
2721cdf0e10cSrcweir     InvalidateFeature( SID_UNDO );
2722cdf0e10cSrcweir }
2723cdf0e10cSrcweir 
2724cdf0e10cSrcweir // -----------------------------------------------------------------------------
getViewData(void)2725cdf0e10cSrcweir uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeException )
2726cdf0e10cSrcweir {
2727cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
2728cdf0e10cSrcweir 
2729cdf0e10cSrcweir     sal_Int32 nCommandIDs[] =
2730cdf0e10cSrcweir     {
2731cdf0e10cSrcweir         SID_GRID_VISIBLE,
2732cdf0e10cSrcweir         SID_GRID_USE,
2733cdf0e10cSrcweir         SID_HELPLINES_MOVE,
2734cdf0e10cSrcweir         SID_RULER,
2735cdf0e10cSrcweir         SID_SHOW_PROPERTYBROWSER,
2736cdf0e10cSrcweir         SID_PROPERTYBROWSER_LAST_PAGE,
2737cdf0e10cSrcweir         SID_SPLIT_POSITION
2738cdf0e10cSrcweir     };
2739cdf0e10cSrcweir 
2740cdf0e10cSrcweir     ::comphelper::NamedValueCollection aCommandProperties;
2741cdf0e10cSrcweir     for ( size_t i=0; i < sizeof( nCommandIDs ) / sizeof( nCommandIDs[0] ); ++i )
2742cdf0e10cSrcweir     {
2743cdf0e10cSrcweir         const FeatureState aFeatureState = GetState( nCommandIDs[i] );
2744cdf0e10cSrcweir 
2745cdf0e10cSrcweir         ::rtl::OUString sCommandURL( getURLForId( nCommandIDs[i] ).Main );
2746cdf0e10cSrcweir         OSL_ENSURE( sCommandURL.indexOfAsciiL( ".uno:", 5 ) == 0, "OReportController::getViewData: illegal command URL!" );
2747cdf0e10cSrcweir         sCommandURL = sCommandURL.copy( 5 );
2748cdf0e10cSrcweir 
2749cdf0e10cSrcweir         Any aCommandState;
2750cdf0e10cSrcweir         if ( !!aFeatureState.bChecked )
2751cdf0e10cSrcweir             aCommandState <<= (*aFeatureState.bChecked) ? sal_True : sal_False;
2752cdf0e10cSrcweir         else if ( aFeatureState.aValue.hasValue() )
2753cdf0e10cSrcweir             aCommandState = aFeatureState.aValue;
2754cdf0e10cSrcweir 
2755cdf0e10cSrcweir         aCommandProperties.put( sCommandURL, aCommandState );
2756cdf0e10cSrcweir     }
2757cdf0e10cSrcweir 
2758cdf0e10cSrcweir     ::comphelper::NamedValueCollection aViewData;
2759cdf0e10cSrcweir     aViewData.put( "CommandProperties", aCommandProperties.getPropertyValues() );
2760cdf0e10cSrcweir 
2761cdf0e10cSrcweir     if ( getDesignView() )
2762cdf0e10cSrcweir     {
2763cdf0e10cSrcweir         ::std::vector<sal_uInt16> aCollapsedPositions;
2764cdf0e10cSrcweir         getDesignView()->fillCollapsedSections(aCollapsedPositions);
2765cdf0e10cSrcweir         if ( !aCollapsedPositions.empty() )
2766cdf0e10cSrcweir         {
2767cdf0e10cSrcweir             uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
2768cdf0e10cSrcweir             beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
2769cdf0e10cSrcweir             ::std::vector<sal_uInt16>::iterator aIter = aCollapsedPositions.begin();
2770cdf0e10cSrcweir             ::std::vector<sal_uInt16>::iterator aEnd = aCollapsedPositions.end();
2771cdf0e10cSrcweir             for (sal_Int32 i = 1; aIter != aEnd ; ++aIter,++pCollapsedIter,++i)
2772cdf0e10cSrcweir             {
2773cdf0e10cSrcweir                 pCollapsedIter->Name = PROPERTY_SECTION + ::rtl::OUString::valueOf(i);
2774cdf0e10cSrcweir                 pCollapsedIter->Value <<= static_cast<sal_Int32>(*aIter);
2775cdf0e10cSrcweir             }
2776cdf0e10cSrcweir 
2777cdf0e10cSrcweir             aViewData.put( "CollapsedSections", aCollapsedSections );
2778cdf0e10cSrcweir         }
2779cdf0e10cSrcweir 
2780cdf0e10cSrcweir         ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
2781cdf0e10cSrcweir         if ( pSectionWindow.get() )
2782cdf0e10cSrcweir         {
2783cdf0e10cSrcweir             aViewData.put( "MarkedSection", (sal_Int32)pSectionWindow->getReportSection().getPage()->GetPageNum() );
2784cdf0e10cSrcweir         } // if ( pSectionWindow.get() )
2785cdf0e10cSrcweir     } // if ( getDesignView() )
2786cdf0e10cSrcweir 
2787cdf0e10cSrcweir     aViewData.put( "ZoomFactor", m_nZoomValue );
2788cdf0e10cSrcweir     return uno::makeAny( aViewData.getPropertyValues() );
2789cdf0e10cSrcweir }
2790cdf0e10cSrcweir // -----------------------------------------------------------------------------
restoreViewData(const uno::Any & i_data)2791cdf0e10cSrcweir void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data) throw( uno::RuntimeException )
2792cdf0e10cSrcweir {
2793cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
2794cdf0e10cSrcweir 
2795cdf0e10cSrcweir     try
2796cdf0e10cSrcweir     {
2797cdf0e10cSrcweir         const ::comphelper::NamedValueCollection aViewData( i_data );
2798cdf0e10cSrcweir 
2799cdf0e10cSrcweir         m_aCollapsedSections = aViewData.getOrDefault( "CollapsedSections", m_aCollapsedSections );
2800cdf0e10cSrcweir         m_nPageNum = aViewData.getOrDefault( "MarkedSection", m_nPageNum );
2801cdf0e10cSrcweir         m_nZoomValue = aViewData.getOrDefault( "ZoomFactor", m_nZoomValue );
2802cdf0e10cSrcweir         // TODO: setting those 3 members is not enough - in theory, restoreViewData can be called when the
2803cdf0e10cSrcweir         // view is fully alive, so we need to reflect those 3 values in the view.
2804cdf0e10cSrcweir         // (At the moment, the method is called only during construction phase)
2805cdf0e10cSrcweir 
2806cdf0e10cSrcweir 
2807cdf0e10cSrcweir         ::comphelper::NamedValueCollection aCommandProperties( aViewData.get( "CommandProperties" ) );
2808cdf0e10cSrcweir         const ::std::vector< ::rtl::OUString > aCommandNames( aCommandProperties.getNames() );
2809cdf0e10cSrcweir 
2810cdf0e10cSrcweir         for (   ::std::vector< ::rtl::OUString >::const_iterator commandName = aCommandNames.begin();
2811cdf0e10cSrcweir                 commandName != aCommandNames.end();
2812cdf0e10cSrcweir                 ++commandName
2813cdf0e10cSrcweir             )
2814cdf0e10cSrcweir         {
2815cdf0e10cSrcweir             const Any& rCommandValue = aCommandProperties.get( *commandName );
2816cdf0e10cSrcweir             if ( !rCommandValue.hasValue() )
2817cdf0e10cSrcweir                 continue;
2818cdf0e10cSrcweir 
2819cdf0e10cSrcweir             if ( getView() )
2820cdf0e10cSrcweir             {
2821cdf0e10cSrcweir                 util::URL aCommand;
2822cdf0e10cSrcweir                 aCommand.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + *commandName;
2823cdf0e10cSrcweir 
2824cdf0e10cSrcweir                 Sequence< PropertyValue > aCommandArgs(1);
2825cdf0e10cSrcweir                 aCommandArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) );
2826cdf0e10cSrcweir                 aCommandArgs[0].Value = rCommandValue;
2827cdf0e10cSrcweir 
2828cdf0e10cSrcweir                 executeUnChecked( aCommand, aCommandArgs );
2829cdf0e10cSrcweir             }
2830cdf0e10cSrcweir             else
2831cdf0e10cSrcweir             {
2832cdf0e10cSrcweir                 if ( commandName->equalsAscii( "ShowRuler" ) )
2833cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_bShowRuler );
2834cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "HelplinesMove" ) )
2835cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_bHelplinesMove );
2836cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "GridVisible" ) )
2837cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_bGridVisible );
2838cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "GridUse" ) )
2839cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_bGridUse );
2840cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "ControlProperties" ) )
2841cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_bShowProperties );
2842cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "LastPropertyBrowserPage" ) )
2843cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_sLastActivePage );
2844cdf0e10cSrcweir                 else if ( commandName->equalsAscii( "SplitPosition" ) )
2845cdf0e10cSrcweir                     OSL_VERIFY( rCommandValue >>= m_nSplitPos );
2846cdf0e10cSrcweir             }
2847cdf0e10cSrcweir         }
2848cdf0e10cSrcweir     }
2849cdf0e10cSrcweir     catch ( const IllegalArgumentException& e )
2850cdf0e10cSrcweir     {
2851cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
2852cdf0e10cSrcweir     }
2853cdf0e10cSrcweir }
2854cdf0e10cSrcweir // -----------------------------------------------------------------------------
updateFloater()2855cdf0e10cSrcweir void OReportController::updateFloater()
2856cdf0e10cSrcweir {
2857cdf0e10cSrcweir    	if ( m_pGroupsFloater && m_pGroupsFloater->IsVisible() )
2858cdf0e10cSrcweir 		m_pGroupsFloater->UpdateData();
2859cdf0e10cSrcweir }
2860cdf0e10cSrcweir 
2861cdf0e10cSrcweir // -----------------------------------------------------------------------------
getXFrame()2862cdf0e10cSrcweir Reference<XFrame> OReportController::getXFrame()
2863cdf0e10cSrcweir {
2864cdf0e10cSrcweir     if ( !m_xFrameLoader.is() )
2865cdf0e10cSrcweir     {
2866cdf0e10cSrcweir         m_xFrameLoader.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),uno::UNO_QUERY_THROW);
2867cdf0e10cSrcweir     }
2868cdf0e10cSrcweir     const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
2869cdf0e10cSrcweir     const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank"));
2870cdf0e10cSrcweir     Reference<XFrame> xFrame = Reference<XFrame>(m_xFrameLoader,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag);
2871cdf0e10cSrcweir     return xFrame;
2872cdf0e10cSrcweir }
2873cdf0e10cSrcweir 
2874cdf0e10cSrcweir // -----------------------------------------------------------------------------
executeReport()2875cdf0e10cSrcweir uno::Reference<frame::XModel> OReportController::executeReport()
2876cdf0e10cSrcweir {
2877cdf0e10cSrcweir     OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?");
2878cdf0e10cSrcweir 
2879cdf0e10cSrcweir     uno::Reference<frame::XModel> xModel;
2880cdf0e10cSrcweir     if ( m_xReportDefinition.is() )
2881cdf0e10cSrcweir     {
2882cdf0e10cSrcweir         sal_uInt16 nErrorId = RID_ERR_NO_COMMAND;
2883cdf0e10cSrcweir         bool bEnabled = m_xReportDefinition->getCommand().getLength() != 0;
2884cdf0e10cSrcweir         if ( bEnabled )
2885cdf0e10cSrcweir         {
2886cdf0e10cSrcweir             bEnabled = false;
2887cdf0e10cSrcweir 	        const sal_uInt16 nCount = m_aReportModel->GetPageCount();
2888cdf0e10cSrcweir             sal_uInt16 i = 0;
2889cdf0e10cSrcweir             for (; i < nCount && !bEnabled ; ++i)
2890cdf0e10cSrcweir             {
2891cdf0e10cSrcweir                 const SdrPage* pPage = m_aReportModel->GetPage(i);
2892cdf0e10cSrcweir                 bEnabled = pPage->GetObjCount() != 0;
2893cdf0e10cSrcweir             }
2894cdf0e10cSrcweir             if ( !bEnabled )
2895cdf0e10cSrcweir                 nErrorId = RID_ERR_NO_OBJECTS;
2896cdf0e10cSrcweir         }
2897cdf0e10cSrcweir 
2898cdf0e10cSrcweir         dbtools::SQLExceptionInfo aInfo;
2899cdf0e10cSrcweir         if ( !bEnabled )
2900cdf0e10cSrcweir         {
2901cdf0e10cSrcweir             sdb::SQLContext aFirstMessage;
2902cdf0e10cSrcweir             String sInfo = String( ModuleRes( nErrorId ) );
2903cdf0e10cSrcweir             aFirstMessage.Message = sInfo;
2904cdf0e10cSrcweir             aInfo = aFirstMessage;
2905cdf0e10cSrcweir             if ( isEditable() )
2906cdf0e10cSrcweir             {
2907cdf0e10cSrcweir                 sal_uInt16 nCommand = 0;
2908cdf0e10cSrcweir                 if ( nErrorId == RID_ERR_NO_COMMAND )
2909cdf0e10cSrcweir                 {
2910cdf0e10cSrcweir                     if ( !m_bShowProperties )
2911cdf0e10cSrcweir                         executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>());
2912cdf0e10cSrcweir 
2913cdf0e10cSrcweir                     m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"));
2914cdf0e10cSrcweir                     getDesignView()->setCurrentPage(m_sLastActivePage);
2915cdf0e10cSrcweir                     nCommand = SID_SELECT_REPORT;
2916cdf0e10cSrcweir                 }
2917cdf0e10cSrcweir                 else if ( getDesignView() && !getDesignView()->isAddFieldVisible() )
2918cdf0e10cSrcweir                 {
2919cdf0e10cSrcweir                     nCommand = SID_FM_ADD_FIELD;
2920cdf0e10cSrcweir                 }
2921cdf0e10cSrcweir                 if ( nCommand )
2922cdf0e10cSrcweir                 {
2923cdf0e10cSrcweir                     uno::Sequence< beans::PropertyValue> aArgs;
2924cdf0e10cSrcweir                     executeUnChecked(nCommand,aArgs);
2925cdf0e10cSrcweir                 }
2926cdf0e10cSrcweir             }
2927cdf0e10cSrcweir         }
2928cdf0e10cSrcweir         else
2929cdf0e10cSrcweir         {
2930cdf0e10cSrcweir             m_bInGeneratePreview = true;
2931cdf0e10cSrcweir             try
2932cdf0e10cSrcweir             {
2933cdf0e10cSrcweir                 WaitObject aWait(getView()); // cursor
2934cdf0e10cSrcweir                 if ( !m_xReportEngine.is() )
2935cdf0e10cSrcweir                     m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW);
2936cdf0e10cSrcweir                 m_xReportEngine->setReportDefinition(m_xReportDefinition);
2937cdf0e10cSrcweir                 m_xReportEngine->setActiveConnection(getConnection());
2938cdf0e10cSrcweir                 Reference<XFrame> xFrame = getXFrame();
2939cdf0e10cSrcweir                 xModel = m_xReportEngine->createDocumentAlive(xFrame);
2940cdf0e10cSrcweir             }
2941cdf0e10cSrcweir             catch( const sdbc::SQLException& /*e*/ )
2942cdf0e10cSrcweir             {   // SQLExceptions and derived exceptions must not be translated
2943cdf0e10cSrcweir                 aInfo = ::cppu::getCaughtException();
2944cdf0e10cSrcweir             }
2945cdf0e10cSrcweir             catch(const uno::Exception& e)
2946cdf0e10cSrcweir             {
2947cdf0e10cSrcweir                 uno::Any aCaughtException( ::cppu::getCaughtException() );
2948cdf0e10cSrcweir 
2949cdf0e10cSrcweir                 // our first message says: we caught an exception
2950cdf0e10cSrcweir                 sdb::SQLContext aFirstMessage;
2951cdf0e10cSrcweir                 String sInfo = String( ModuleRes( RID_STR_CAUGHT_FOREIGN_EXCEPTION ) );
2952cdf0e10cSrcweir                 sInfo.SearchAndReplaceAllAscii( "$type$", aCaughtException.getValueTypeName() );
2953cdf0e10cSrcweir                 aFirstMessage.Message = sInfo;
2954cdf0e10cSrcweir 
2955cdf0e10cSrcweir                 // our second message: the message of the exception we caught
2956cdf0e10cSrcweir                 sdbc::SQLException aSecondMessage;
2957cdf0e10cSrcweir                 aSecondMessage.Message = e.Message;
2958cdf0e10cSrcweir                 aSecondMessage.Context = e.Context;
2959cdf0e10cSrcweir 
2960cdf0e10cSrcweir                 // maybe our third message: the message which is wrapped in the exception we caught
2961cdf0e10cSrcweir                 sdbc::SQLException aThirdMessage;
2962cdf0e10cSrcweir                 lang::WrappedTargetException aWrapped;
2963cdf0e10cSrcweir                 if ( aCaughtException >>= aWrapped )
2964cdf0e10cSrcweir                 {
2965cdf0e10cSrcweir                     aThirdMessage.Message = aWrapped.Message;
2966cdf0e10cSrcweir                     aThirdMessage.Context = aWrapped.Context;
2967cdf0e10cSrcweir                 }
2968cdf0e10cSrcweir 
2969cdf0e10cSrcweir                 if ( aThirdMessage.Message.getLength() )
2970cdf0e10cSrcweir                     aSecondMessage.NextException <<= aThirdMessage;
2971cdf0e10cSrcweir                 aFirstMessage.NextException <<= aSecondMessage;
2972cdf0e10cSrcweir 
2973cdf0e10cSrcweir                 aInfo = aFirstMessage;
2974cdf0e10cSrcweir             }
2975cdf0e10cSrcweir             if (aInfo.isValid())
2976cdf0e10cSrcweir             {
2977cdf0e10cSrcweir                 const String suSQLContext = String( ModuleRes( RID_STR_COULD_NOT_CREATE_REPORT ) );
2978cdf0e10cSrcweir                 aInfo.prepend(suSQLContext);
2979cdf0e10cSrcweir             } // if (aInfo.isValid())
2980cdf0e10cSrcweir             m_bInGeneratePreview = false;
2981cdf0e10cSrcweir         }
2982cdf0e10cSrcweir 
2983cdf0e10cSrcweir         if (aInfo.isValid())
2984cdf0e10cSrcweir         {
2985cdf0e10cSrcweir             showError(aInfo);
2986cdf0e10cSrcweir         }
2987cdf0e10cSrcweir     }
2988cdf0e10cSrcweir     return xModel;
2989cdf0e10cSrcweir }
2990cdf0e10cSrcweir // -----------------------------------------------------------------------------
getModel(void)2991cdf0e10cSrcweir uno::Reference< frame::XModel >  SAL_CALL OReportController::getModel(void) throw( uno::RuntimeException )
2992cdf0e10cSrcweir {
2993cdf0e10cSrcweir 	return m_xReportDefinition.get();
2994cdf0e10cSrcweir }
2995cdf0e10cSrcweir // -----------------------------------------------------------------------------
getRowSet()2996cdf0e10cSrcweir uno::Reference< sdbc::XRowSet > OReportController::getRowSet()
2997cdf0e10cSrcweir {
2998cdf0e10cSrcweir     OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" );
2999cdf0e10cSrcweir 
3000cdf0e10cSrcweir     if ( m_xRowSet.is() || !m_xReportDefinition.is() )
3001cdf0e10cSrcweir         return m_xRowSet;
3002cdf0e10cSrcweir 
3003cdf0e10cSrcweir     try
3004cdf0e10cSrcweir     {
3005cdf0e10cSrcweir         uno::Reference< sdbc::XRowSet > xRowSet( getORB()->createInstance(
3006cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.RowSet" ) ) ), uno::UNO_QUERY );
3007cdf0e10cSrcweir         uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW );
3008cdf0e10cSrcweir 
3009cdf0e10cSrcweir         xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) );
3010cdf0e10cSrcweir         xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( sal_True ) );
3011cdf0e10cSrcweir 
3012cdf0e10cSrcweir         ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
3013cdf0e10cSrcweir         TPropertyNamePair aPropertyMediation;
3014cdf0e10cSrcweir         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) ) );
3015cdf0e10cSrcweir         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) ) );
3016cdf0e10cSrcweir         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) ) );
3017cdf0e10cSrcweir         aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) ) );
3018cdf0e10cSrcweir 
3019cdf0e10cSrcweir         m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation );
3020cdf0e10cSrcweir         m_xRowSet = xRowSet;
3021cdf0e10cSrcweir     }
3022cdf0e10cSrcweir     catch( const uno::Exception& )
3023cdf0e10cSrcweir     {
3024cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
3025cdf0e10cSrcweir     }
3026cdf0e10cSrcweir 
3027cdf0e10cSrcweir     return m_xRowSet;
3028cdf0e10cSrcweir }
3029cdf0e10cSrcweir // -----------------------------------------------------------------------------
insertGraphic()3030cdf0e10cSrcweir void OReportController::insertGraphic()
3031cdf0e10cSrcweir {
3032cdf0e10cSrcweir     const String sTitle(ModuleRes(RID_STR_IMPORT_GRAPHIC));
3033cdf0e10cSrcweir 	// build some arguments for the upcoming dialog
3034cdf0e10cSrcweir 	try
3035cdf0e10cSrcweir 	{
3036cdf0e10cSrcweir         uno::Reference< report::XSection> xSection = getDesignView()->getCurrentSection();
3037cdf0e10cSrcweir 		::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC );
3038cdf0e10cSrcweir 		aDialog.SetTitle( sTitle );
3039cdf0e10cSrcweir 
3040cdf0e10cSrcweir         uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
3041cdf0e10cSrcweir 		xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));
3042cdf0e10cSrcweir 		xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False/*sal_True*/);
3043cdf0e10cSrcweir         sal_Bool bLink = sal_True;
3044cdf0e10cSrcweir         xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any( bLink ) );
3045cdf0e10cSrcweir 
3046cdf0e10cSrcweir 		if ( ERRCODE_NONE == aDialog.Execute() )
3047cdf0e10cSrcweir         {
3048cdf0e10cSrcweir             xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink;
3049cdf0e10cSrcweir             uno::Sequence<beans::PropertyValue> aArgs(2);
3050cdf0e10cSrcweir             aArgs[0].Name = PROPERTY_IMAGEURL;
3051cdf0e10cSrcweir             aArgs[0].Value <<= ::rtl::OUString(aDialog.GetPath());
3052cdf0e10cSrcweir             aArgs[1].Name = PROPERTY_PRESERVEIRI;
3053cdf0e10cSrcweir             aArgs[1].Value <<= bLink;
3054cdf0e10cSrcweir             createControl(aArgs,xSection,::rtl::OUString(),OBJ_DLG_IMAGECONTROL);
3055cdf0e10cSrcweir         }
3056cdf0e10cSrcweir 	}
3057cdf0e10cSrcweir 	catch(Exception&)
3058cdf0e10cSrcweir 	{
3059cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
3060cdf0e10cSrcweir 	}
3061cdf0e10cSrcweir }
3062cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSdrModel() const3063cdf0e10cSrcweir ::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel() const
3064cdf0e10cSrcweir {
3065cdf0e10cSrcweir     return m_aReportModel;
3066cdf0e10cSrcweir }
3067cdf0e10cSrcweir // -----------------------------------------------------------------------------
select(const Any & aSelection)3068cdf0e10cSrcweir ::sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) throw (IllegalArgumentException, RuntimeException)
3069cdf0e10cSrcweir {
3070cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
3071cdf0e10cSrcweir     ::sal_Bool bRet = sal_True;
3072cdf0e10cSrcweir     if ( getDesignView() )
3073cdf0e10cSrcweir     {
3074cdf0e10cSrcweir         getDesignView()->unmarkAllObjects(NULL);
3075cdf0e10cSrcweir         getDesignView()->SetMode(RPTUI_SELECT);
3076cdf0e10cSrcweir 
3077cdf0e10cSrcweir         uno::Sequence< uno::Reference<report::XReportComponent> > aElements;
3078cdf0e10cSrcweir         if ( aSelection >>= aElements )
3079cdf0e10cSrcweir         {
3080cdf0e10cSrcweir             if ( aElements.getLength() > 0 )
3081cdf0e10cSrcweir                 getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY));
3082cdf0e10cSrcweir             getDesignView()->setMarked(aElements,sal_True);
3083cdf0e10cSrcweir         }
3084cdf0e10cSrcweir         else
3085cdf0e10cSrcweir         {
3086cdf0e10cSrcweir             uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY);
3087cdf0e10cSrcweir             uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY);
3088cdf0e10cSrcweir             if ( xProp.is() )
3089cdf0e10cSrcweir             {
3090cdf0e10cSrcweir                 getDesignView()->showProperties(xObject);
3091cdf0e10cSrcweir                 aElements.realloc(1);
3092cdf0e10cSrcweir                 aElements[0] = xProp;
3093cdf0e10cSrcweir                 getDesignView()->setMarked(aElements,sal_True);
3094cdf0e10cSrcweir             }
3095cdf0e10cSrcweir             else
3096cdf0e10cSrcweir             {
3097cdf0e10cSrcweir                 uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY);
3098cdf0e10cSrcweir                 if ( !xSection.is() && xObject.is() )
3099cdf0e10cSrcweir                     getDesignView()->showProperties(xObject);
3100cdf0e10cSrcweir                 getDesignView()->setMarked(xSection,xSection.is());
3101cdf0e10cSrcweir             }
3102cdf0e10cSrcweir         }
3103cdf0e10cSrcweir         InvalidateAll();
3104cdf0e10cSrcweir     }
3105cdf0e10cSrcweir     return bRet;
3106cdf0e10cSrcweir }
3107cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSelection()3108cdf0e10cSrcweir Any SAL_CALL OReportController::getSelection(  ) throw (RuntimeException)
3109cdf0e10cSrcweir {
3110cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
3111cdf0e10cSrcweir     Any aRet;
3112cdf0e10cSrcweir     if ( getDesignView() )
3113cdf0e10cSrcweir     {
3114cdf0e10cSrcweir         aRet = getDesignView()->getCurrentlyShownProperty();
3115cdf0e10cSrcweir 		if ( !aRet.hasValue() )
3116cdf0e10cSrcweir 			aRet <<= getDesignView()->getCurrentSection();
3117cdf0e10cSrcweir     }
3118cdf0e10cSrcweir     return aRet;
3119cdf0e10cSrcweir }
3120cdf0e10cSrcweir // -----------------------------------------------------------------------------
addSelectionChangeListener(const Reference<view::XSelectionChangeListener> & _Listener)3121cdf0e10cSrcweir void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
3122cdf0e10cSrcweir {
3123cdf0e10cSrcweir     m_aSelectionListeners.addInterface( _Listener );
3124cdf0e10cSrcweir }
3125cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeSelectionChangeListener(const Reference<view::XSelectionChangeListener> & _Listener)3126cdf0e10cSrcweir void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
3127cdf0e10cSrcweir {
3128cdf0e10cSrcweir     m_aSelectionListeners.removeInterface( _Listener );
3129cdf0e10cSrcweir }
3130cdf0e10cSrcweir // -----------------------------------------------------------------------------
createNewFunction(const uno::Any & _aValue)3131cdf0e10cSrcweir void OReportController::createNewFunction(const uno::Any& _aValue)
3132cdf0e10cSrcweir {
3133cdf0e10cSrcweir     uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW);
3134cdf0e10cSrcweir     const ::rtl::OUString sNewName = String(ModuleRes(RID_STR_FUNCTION));
3135cdf0e10cSrcweir     uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext));
3136cdf0e10cSrcweir     xFunction->setName(sNewName);
3137cdf0e10cSrcweir     // the call below will also create an undo action -> listener
3138cdf0e10cSrcweir     xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction));
3139cdf0e10cSrcweir }
3140cdf0e10cSrcweir // -----------------------------------------------------------------------------
3141cdf0e10cSrcweir IMPL_LINK( OReportController, OnExecuteReport, void* ,/*_pMemfun*/)
3142cdf0e10cSrcweir {
3143cdf0e10cSrcweir     //m_nExecuteReportEvent = 0;
3144cdf0e10cSrcweir     executeReport();
3145cdf0e10cSrcweir     return 0L;
3146cdf0e10cSrcweir }
3147cdf0e10cSrcweir // -----------------------------------------------------------------------------
createControl(const Sequence<PropertyValue> & _aArgs,const uno::Reference<report::XSection> & _xSection,const::rtl::OUString & _sFunction,sal_uInt16 _nObjectId)3148cdf0e10cSrcweir void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const ::rtl::OUString& _sFunction,sal_uInt16 _nObjectId)
3149cdf0e10cSrcweir {
3150cdf0e10cSrcweir     SequenceAsHashMap aMap(_aArgs);
3151cdf0e10cSrcweir     getDesignView()->setMarked(_xSection ,sal_True);
3152cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
3153cdf0e10cSrcweir     if ( !pSectionWindow )
3154cdf0e10cSrcweir         return;
3155cdf0e10cSrcweir 
3156cdf0e10cSrcweir     OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the corrct one.");
3157cdf0e10cSrcweir 
3158cdf0e10cSrcweir     sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3159cdf0e10cSrcweir     const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3160cdf0e10cSrcweir     const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3161cdf0e10cSrcweir     awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3162cdf0e10cSrcweir     if ( aPos.X < nLeftMargin )
3163cdf0e10cSrcweir         aPos.X = nLeftMargin;
3164cdf0e10cSrcweir 
3165cdf0e10cSrcweir     SdrObject* pNewControl = NULL;
3166cdf0e10cSrcweir     uno::Reference< report::XReportComponent> xShapeProp;
3167cdf0e10cSrcweir     if ( _nObjectId == OBJ_CUSTOMSHAPE )
3168cdf0e10cSrcweir     {
3169cdf0e10cSrcweir         pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
3170cdf0e10cSrcweir         xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY);
3171cdf0e10cSrcweir 		::rtl::OUString sCustomShapeType = getDesignView()->GetInsertObjString();
3172cdf0e10cSrcweir         if ( !sCustomShapeType.getLength() )
3173cdf0e10cSrcweir             sCustomShapeType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond"));
3174cdf0e10cSrcweir         pSectionWindow->getReportSection().createDefault(sCustomShapeType,pNewControl);
3175cdf0e10cSrcweir 		pNewControl->SetLogicRect(Rectangle(3000,500,6000,3500)); // switch height and width
3176cdf0e10cSrcweir     } // if ( _nObjectId == OBJ_CUSTOMSHAPE )
3177cdf0e10cSrcweir     else if ( _nObjectId == OBJ_OLE2 || OBJ_DLG_SUBREPORT == _nObjectId  )
3178cdf0e10cSrcweir     {
3179cdf0e10cSrcweir         pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
3180cdf0e10cSrcweir 
3181cdf0e10cSrcweir         pNewControl->SetLogicRect(Rectangle(3000,500,8000,5500)); // switch height and width
3182cdf0e10cSrcweir         xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
3183cdf0e10cSrcweir         OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
3184cdf0e10cSrcweir         if ( pObj && !pObj->IsEmpty() )
3185cdf0e10cSrcweir         {
3186cdf0e10cSrcweir             pObj->initializeChart(getModel());
3187cdf0e10cSrcweir         }
3188cdf0e10cSrcweir     }
3189cdf0e10cSrcweir     else
3190cdf0e10cSrcweir     {
3191cdf0e10cSrcweir         SdrUnoObj* pLabel( NULL );
3192cdf0e10cSrcweir         SdrUnoObj* pControl( NULL );
3193cdf0e10cSrcweir         FmFormView::createControlLabelPair( getDesignView()
3194cdf0e10cSrcweir                             ,nLeftMargin,0
3195cdf0e10cSrcweir                             ,NULL,NULL,_nObjectId,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
3196cdf0e10cSrcweir  					    NULL,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(),
3197cdf0e10cSrcweir  					    pLabel,pControl);
3198cdf0e10cSrcweir         delete pLabel;
3199cdf0e10cSrcweir 
3200cdf0e10cSrcweir         pNewControl = pControl;
3201cdf0e10cSrcweir         OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
3202cdf0e10cSrcweir         uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
3203cdf0e10cSrcweir         xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
3204cdf0e10cSrcweir         uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3205cdf0e10cSrcweir         uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3206cdf0e10cSrcweir 
3207cdf0e10cSrcweir         const ::rtl::OUString sProps[] = {   PROPERTY_NAME
3208cdf0e10cSrcweir                                             ,PROPERTY_FONTDESCRIPTOR
3209cdf0e10cSrcweir                                             ,PROPERTY_FONTDESCRIPTORASIAN
3210cdf0e10cSrcweir                                             ,PROPERTY_FONTDESCRIPTORCOMPLEX
3211cdf0e10cSrcweir                                             ,PROPERTY_ORIENTATION
3212cdf0e10cSrcweir                                             ,PROPERTY_BORDER
3213cdf0e10cSrcweir                                             ,PROPERTY_FORMATSSUPPLIER
3214cdf0e10cSrcweir                                             ,PROPERTY_BACKGROUNDCOLOR
3215cdf0e10cSrcweir         };
3216cdf0e10cSrcweir         for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i)
3217cdf0e10cSrcweir         {
3218cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
3219cdf0e10cSrcweir                 xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
3220cdf0e10cSrcweir         } // for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i)
3221cdf0e10cSrcweir 
3222cdf0e10cSrcweir         if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3223cdf0e10cSrcweir             xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3224cdf0e10cSrcweir 
3225cdf0e10cSrcweir 
3226cdf0e10cSrcweir         if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && _sFunction.getLength() )
3227cdf0e10cSrcweir         {
3228cdf0e10cSrcweir             ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
3229cdf0e10cSrcweir             xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
3230cdf0e10cSrcweir         }
3231cdf0e10cSrcweir 
3232cdf0e10cSrcweir         sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
3233cdf0e10cSrcweir         if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
3234cdf0e10cSrcweir             xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
3235cdf0e10cSrcweir 
3236cdf0e10cSrcweir         ::rtl::OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,::rtl::OUString());
3237cdf0e10cSrcweir         if ( sUrl.getLength() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
3238cdf0e10cSrcweir             xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
3239cdf0e10cSrcweir 
3240cdf0e10cSrcweir         pObj->CreateMediator(sal_True);
3241cdf0e10cSrcweir 
3242cdf0e10cSrcweir         if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
3243cdf0e10cSrcweir             xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
3244cdf0e10cSrcweir         else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
3245cdf0e10cSrcweir         {
3246cdf0e10cSrcweir             awt::Size aOlSize = xShapeProp->getSize();
3247cdf0e10cSrcweir             xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
3248cdf0e10cSrcweir         }
3249cdf0e10cSrcweir     }
3250cdf0e10cSrcweir 
3251cdf0e10cSrcweir     const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
3252cdf0e10cSrcweir     if ( nShapeWidth != xShapeProp->getWidth() )
3253cdf0e10cSrcweir         xShapeProp->setWidth( nShapeWidth );
3254cdf0e10cSrcweir 
3255cdf0e10cSrcweir     const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3256cdf0e10cSrcweir     if ( bChangedPos )
3257cdf0e10cSrcweir         aPos.X = nPaperWidth - nShapeWidth;
3258cdf0e10cSrcweir     xShapeProp->setPosition(aPos);
3259cdf0e10cSrcweir 
3260cdf0e10cSrcweir     correctOverlapping(pNewControl,pSectionWindow->getReportSection());
3261cdf0e10cSrcweir }
3262cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDateTime(const Sequence<PropertyValue> & _aArgs)3263cdf0e10cSrcweir void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
3264cdf0e10cSrcweir {
3265cdf0e10cSrcweir     getDesignView()->unmarkAllObjects(NULL);
3266cdf0e10cSrcweir 
3267cdf0e10cSrcweir     const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
3268cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), sUndoAction );
3269cdf0e10cSrcweir 
3270cdf0e10cSrcweir     SequenceAsHashMap aMap(_aArgs);
3271cdf0e10cSrcweir     aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0)));
3272cdf0e10cSrcweir 
3273cdf0e10cSrcweir     uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>());
3274cdf0e10cSrcweir     ::rtl::OUString sFunction;
3275cdf0e10cSrcweir 
3276cdf0e10cSrcweir     sal_Bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE,sal_False);
3277cdf0e10cSrcweir     if ( bDate )
3278cdf0e10cSrcweir     {
3279cdf0e10cSrcweir         sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TODAY()"));
3280cdf0e10cSrcweir         createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3281cdf0e10cSrcweir     }
3282cdf0e10cSrcweir     sal_Bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE,sal_False);
3283cdf0e10cSrcweir     if ( bTime )
3284cdf0e10cSrcweir     {
3285cdf0e10cSrcweir         sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TIMEVALUE(NOW())"));
3286cdf0e10cSrcweir         aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0));
3287cdf0e10cSrcweir         createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3288cdf0e10cSrcweir     }
3289cdf0e10cSrcweir }
3290cdf0e10cSrcweir // -----------------------------------------------------------------------------
createPageNumber(const Sequence<PropertyValue> & _aArgs)3291cdf0e10cSrcweir void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs)
3292cdf0e10cSrcweir {
3293cdf0e10cSrcweir     getDesignView()->unmarkAllObjects(NULL);
3294cdf0e10cSrcweir 
3295cdf0e10cSrcweir     const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
3296cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), sUndoAction );
3297cdf0e10cSrcweir 
3298cdf0e10cSrcweir     if ( !m_xReportDefinition->getPageHeaderOn() )
3299cdf0e10cSrcweir 	{
3300cdf0e10cSrcweir 		uno::Sequence< beans::PropertyValue > aArgs;
3301cdf0e10cSrcweir 		executeChecked(SID_PAGEHEADERFOOTER,aArgs);
3302cdf0e10cSrcweir 	} // if ( !m_xHoldAlive->getPageHeaderOn() )
3303cdf0e10cSrcweir 
3304cdf0e10cSrcweir     SequenceAsHashMap aMap(_aArgs);
3305cdf0e10cSrcweir     sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False);
3306cdf0e10cSrcweir 
3307cdf0e10cSrcweir     String sFunction = String(ModuleRes(STR_RPT_PN_PAGE));
3308cdf0e10cSrcweir     ::rtl::OUString sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()"));
3309cdf0e10cSrcweir     sFunction.SearchAndReplace(String::CreateFromAscii("#PAGENUMBER#"),sPageNumber);
3310cdf0e10cSrcweir 
3311cdf0e10cSrcweir     if ( bStateOfPage )
3312cdf0e10cSrcweir     {
3313cdf0e10cSrcweir         ::rtl::OUString sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()"));
3314cdf0e10cSrcweir         sFunction += String(ModuleRes(STR_RPT_PN_PAGE_OF));
3315cdf0e10cSrcweir         sFunction.SearchAndReplace(String::CreateFromAscii("#PAGECOUNT#"),sPageCount);
3316cdf0e10cSrcweir     }
3317cdf0e10cSrcweir 
3318cdf0e10cSrcweir     sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True);
3319cdf0e10cSrcweir     createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction);
3320cdf0e10cSrcweir }
3321cdf0e10cSrcweir 
3322cdf0e10cSrcweir // -----------------------------------------------------------------------------
addPairControls(const Sequence<PropertyValue> & aArgs)3323cdf0e10cSrcweir void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
3324cdf0e10cSrcweir {
3325cdf0e10cSrcweir     getDesignView()->unmarkAllObjects(NULL);
3326cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
3327cdf0e10cSrcweir 	// Anhand des FormatKeys wird festgestellt, welches Feld benoetigt wird
3328cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pSectionWindow[2];
3329cdf0e10cSrcweir     pSectionWindow[0] = getDesignView()->getMarkedSection();
3330cdf0e10cSrcweir 
3331cdf0e10cSrcweir 	if ( !pSectionWindow[0] )
3332cdf0e10cSrcweir     {
3333cdf0e10cSrcweir         select(uno::makeAny(m_xReportDefinition->getDetail()));
3334cdf0e10cSrcweir         pSectionWindow[0] = getDesignView()->getMarkedSection();
3335cdf0e10cSrcweir         if ( !pSectionWindow[0] )
3336cdf0e10cSrcweir             return;
3337cdf0e10cSrcweir     }
3338cdf0e10cSrcweir 
3339cdf0e10cSrcweir     uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection();
3340cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) );
3341cdf0e10cSrcweir 
3342cdf0e10cSrcweir     try
3343cdf0e10cSrcweir     {
3344cdf0e10cSrcweir         bool bHandleOnlyOne = false;
3345cdf0e10cSrcweir         const PropertyValue* pIter = aArgs.getConstArray();
3346cdf0e10cSrcweir         const PropertyValue* pEnd  = pIter + aArgs.getLength();
3347cdf0e10cSrcweir         for(;pIter != pEnd && !bHandleOnlyOne;++pIter)
3348cdf0e10cSrcweir         {
3349cdf0e10cSrcweir             Sequence< PropertyValue > aValue;
3350cdf0e10cSrcweir             if ( !(pIter->Value >>= aValue) )
3351cdf0e10cSrcweir             {   // the sequence has only one element which already contains the descriptor
3352cdf0e10cSrcweir                 bHandleOnlyOne = true;
3353cdf0e10cSrcweir                 aValue = aArgs;
3354cdf0e10cSrcweir             }
3355cdf0e10cSrcweir             ::svx::ODataAccessDescriptor aDescriptor(aValue);
3356cdf0e10cSrcweir             SequenceAsHashMap aMap(aValue);
3357cdf0e10cSrcweir             uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Section")),xCurrentSection);
3358cdf0e10cSrcweir             uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
3359cdf0e10cSrcweir 
3360cdf0e10cSrcweir             getDesignView()->setMarked(xSection,sal_True);
3361cdf0e10cSrcweir             pSectionWindow[0] = getDesignView()->getMarkedSection();
3362cdf0e10cSrcweir 
3363cdf0e10cSrcweir             sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3364cdf0e10cSrcweir             awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3365cdf0e10cSrcweir             if ( aPos.X < nLeftMargin )
3366cdf0e10cSrcweir                 aPos.X = nLeftMargin;
3367cdf0e10cSrcweir 
3368cdf0e10cSrcweir 		    // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down
3369cdf0e10cSrcweir 		    sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DNDAction")), sal_Int8(0));
3370cdf0e10cSrcweir 		    pSectionWindow[1] = pSectionWindow[0];
3371cdf0e10cSrcweir 		    // ::boost::shared_ptr<OReportSection> pReportSectionPost;
3372cdf0e10cSrcweir 		    sal_Bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY;
3373cdf0e10cSrcweir 		    if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK )
3374cdf0e10cSrcweir 		    {
3375cdf0e10cSrcweir 			    // Add the Label one Section up
3376cdf0e10cSrcweir                 pSectionWindow[1] = getDesignView()->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST);
3377cdf0e10cSrcweir 			    if (!pSectionWindow[1])
3378cdf0e10cSrcweir 			    {
3379cdf0e10cSrcweir 				    // maybe out of bounds
3380cdf0e10cSrcweir 				    pSectionWindow[1] = pSectionWindow[0];
3381cdf0e10cSrcweir 			    }
3382cdf0e10cSrcweir 		    }
3383cdf0e10cSrcweir             // clear all selections
3384cdf0e10cSrcweir             getDesignView()->unmarkAllObjects(NULL);
3385cdf0e10cSrcweir 
3386cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xField( aDescriptor[ ::svx::daColumnObject ], uno::UNO_QUERY );
3387cdf0e10cSrcweir             uno::Reference< lang::XComponent > xHoldAlive;
3388cdf0e10cSrcweir             if ( !xField.is() )
3389cdf0e10cSrcweir             {
3390cdf0e10cSrcweir                 ::rtl::OUString sCommand;
3391cdf0e10cSrcweir                 ::rtl::OUString sColumnName;
3392cdf0e10cSrcweir                 sal_Int32 nCommandType( -1 );
3393cdf0e10cSrcweir                 OSL_VERIFY( aDescriptor[ ::svx::daCommand ] >>= sCommand );
3394cdf0e10cSrcweir                 OSL_VERIFY( aDescriptor[ ::svx::daColumnName ] >>= sColumnName );
3395cdf0e10cSrcweir                 OSL_VERIFY( aDescriptor[ ::svx::daCommandType ] >>= nCommandType );
3396cdf0e10cSrcweir 
3397cdf0e10cSrcweir                 uno::Reference< container::XNameAccess > xColumns;
3398cdf0e10cSrcweir                 uno::Reference< sdbc::XConnection > xConnection( getConnection() );
3399cdf0e10cSrcweir                 if ( sCommand.getLength() && nCommandType != -1 && sColumnName.getLength() && xConnection.is() )
3400cdf0e10cSrcweir                 {
3401cdf0e10cSrcweir                     if ( !xReportDefinition->getCommand().getLength() )
3402cdf0e10cSrcweir                     {
3403cdf0e10cSrcweir                         xReportDefinition->setCommand(sCommand);
3404cdf0e10cSrcweir                         xReportDefinition->setCommandType(nCommandType);
3405cdf0e10cSrcweir                     } // if ( !xReportDefinition->getCommand().getLength() )
3406cdf0e10cSrcweir 
3407cdf0e10cSrcweir 			        xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive);
3408cdf0e10cSrcweir                     if ( xColumns.is() && xColumns->hasByName(sColumnName) )
3409cdf0e10cSrcweir                         xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY );
3410cdf0e10cSrcweir                 }
3411cdf0e10cSrcweir 
3412cdf0e10cSrcweir                 if ( !xField.is() )
3413cdf0e10cSrcweir                 {
3414cdf0e10cSrcweir                 #if OSL_DEBUG_LEVEL > 0
3415cdf0e10cSrcweir                     try
3416cdf0e10cSrcweir                     {
3417cdf0e10cSrcweir                         uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
3418cdf0e10cSrcweir                         ::rtl::OUString sRowSetCommand;
3419cdf0e10cSrcweir                         sal_Int32 nRowSetCommandType( -1 );
3420cdf0e10cSrcweir                         OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand );
3421cdf0e10cSrcweir                         OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType );
3422cdf0e10cSrcweir                         OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ),
3423cdf0e10cSrcweir                             "OReportController::addPairControls: this only works for a data source which equals our current settings!" );
3424cdf0e10cSrcweir                         // if this asserts, then either our row set and our report definition are not in sync, or somebody
3425cdf0e10cSrcweir                         // requested the creation of a control/pair for another data source than what our report
3426cdf0e10cSrcweir                         // definition is bound to - which is not supported for the parameters case, since we
3427cdf0e10cSrcweir                         // can retrieve parameters from the RowSet only.
3428cdf0e10cSrcweir                     }
3429cdf0e10cSrcweir                     catch( const Exception& )
3430cdf0e10cSrcweir                     {
3431cdf0e10cSrcweir             	        DBG_UNHANDLED_EXCEPTION();
3432cdf0e10cSrcweir                     }
3433cdf0e10cSrcweir                 #endif
3434cdf0e10cSrcweir 
3435cdf0e10cSrcweir                     // no column name - perhaps a parameter name?
3436cdf0e10cSrcweir                     uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW );
3437cdf0e10cSrcweir                     uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_QUERY_THROW );
3438cdf0e10cSrcweir                     sal_Int32 nParamCount( xParams->getCount() );
3439cdf0e10cSrcweir                     for ( sal_Int32 i=0; i<nParamCount; ++i)
3440cdf0e10cSrcweir                     {
3441cdf0e10cSrcweir                         uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
3442cdf0e10cSrcweir                         ::rtl::OUString sParamName;
3443cdf0e10cSrcweir                         OSL_VERIFY( xParamCol->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sParamName );
3444cdf0e10cSrcweir                         if ( sParamName == sColumnName )
3445cdf0e10cSrcweir                         {
3446cdf0e10cSrcweir                             xField = xParamCol;
3447cdf0e10cSrcweir                             break;
3448cdf0e10cSrcweir                         }
3449cdf0e10cSrcweir                     }
3450cdf0e10cSrcweir                 }
3451cdf0e10cSrcweir             }
3452cdf0e10cSrcweir 		    if ( !xField.is() )
3453cdf0e10cSrcweir                 continue;
3454cdf0e10cSrcweir 
3455cdf0e10cSrcweir             sal_uInt16 nOBJID = 0;
3456cdf0e10cSrcweir 		    sal_Int32 nDataType = sdbc::DataType::BINARY;
3457cdf0e10cSrcweir 		    xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
3458cdf0e10cSrcweir 		    switch ( nDataType )
3459cdf0e10cSrcweir 		    {
3460cdf0e10cSrcweir                 case sdbc::DataType::BINARY:
3461cdf0e10cSrcweir 			    case sdbc::DataType::VARBINARY:
3462cdf0e10cSrcweir 			    case sdbc::DataType::LONGVARBINARY:
3463cdf0e10cSrcweir 				    nOBJID = OBJ_DLG_IMAGECONTROL;
3464cdf0e10cSrcweir 				    break;
3465cdf0e10cSrcweir 			    default:
3466cdf0e10cSrcweir 				    nOBJID = OBJ_DLG_FORMATTEDFIELD;
3467cdf0e10cSrcweir 				    break;
3468cdf0e10cSrcweir 		    }
3469cdf0e10cSrcweir 
3470cdf0e10cSrcweir             if ( !nOBJID )
3471cdf0e10cSrcweir                 continue;
3472cdf0e10cSrcweir 
3473cdf0e10cSrcweir             Reference< util::XNumberFormatsSupplier >  xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier();
3474cdf0e10cSrcweir             if ( !xSupplier.is() )
3475cdf0e10cSrcweir                 continue;
3476cdf0e10cSrcweir 
3477cdf0e10cSrcweir             Reference< XNumberFormats >  xNumberFormats(xSupplier->getNumberFormats());
3478cdf0e10cSrcweir 		    SdrUnoObj* pControl[2];
3479cdf0e10cSrcweir 		    pControl[0] = NULL;
3480cdf0e10cSrcweir 		    pControl[1] = NULL;
3481cdf0e10cSrcweir             //getDesignView()->GetModel()->GetUndoEnv().Lock();
3482cdf0e10cSrcweir             const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3483cdf0e10cSrcweir             const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3484cdf0e10cSrcweir 		    OSectionView* pSectionViews[2];
3485cdf0e10cSrcweir 		    pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView();
3486cdf0e10cSrcweir 		    pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView();
3487cdf0e10cSrcweir             // find this in svx
3488cdf0e10cSrcweir 		    FmFormView::createControlLabelPair( getDesignView()
3489cdf0e10cSrcweir                 ,nLeftMargin,0
3490cdf0e10cSrcweir                 ,xField,xNumberFormats,nOBJID,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
3491cdf0e10cSrcweir 			    pSectionWindow[1]->getReportSection().getPage(),pSectionWindow[0]->getReportSection().getPage(),m_aReportModel.get(),
3492cdf0e10cSrcweir 			    pControl[0],pControl[1]);
3493cdf0e10cSrcweir             //getDesignView()->GetModel()->GetUndoEnv().UnLock();
3494cdf0e10cSrcweir 		    if ( pControl[0] && pControl[1] )
3495cdf0e10cSrcweir 		    {
3496cdf0e10cSrcweir 			    SdrPageView* pPgViews[2];
3497cdf0e10cSrcweir 			    pPgViews[0] = pSectionViews[0]->GetSdrPageView();
3498cdf0e10cSrcweir 			    pPgViews[1] = pSectionViews[1]->GetSdrPageView();
3499cdf0e10cSrcweir 			    if ( pPgViews[0] && pPgViews[1] )
3500cdf0e10cSrcweir 			    {
3501cdf0e10cSrcweir                     ::rtl::OUString sDefaultName;
3502cdf0e10cSrcweir                     size_t i = 0;
3503cdf0e10cSrcweir                     OUnoObject* pObjs[2];
3504cdf0e10cSrcweir 				    for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
3505cdf0e10cSrcweir 				    {
3506cdf0e10cSrcweir                         pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]);
3507cdf0e10cSrcweir                         uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
3508cdf0e10cSrcweir                         uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
3509cdf0e10cSrcweir                         xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
3510cdf0e10cSrcweir 
3511cdf0e10cSrcweir                         uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3512cdf0e10cSrcweir                         uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3513cdf0e10cSrcweir                         const ::rtl::OUString sProps[] = {   PROPERTY_FONTDESCRIPTOR
3514cdf0e10cSrcweir                                                             ,PROPERTY_FONTDESCRIPTORASIAN
3515cdf0e10cSrcweir                                                             ,PROPERTY_FONTDESCRIPTORCOMPLEX
3516cdf0e10cSrcweir                                                             ,PROPERTY_BORDER
3517cdf0e10cSrcweir                                                             ,PROPERTY_BACKGROUNDCOLOR
3518cdf0e10cSrcweir                         };
3519cdf0e10cSrcweir                         for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k)
3520cdf0e10cSrcweir                         {
3521cdf0e10cSrcweir                             if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) )
3522cdf0e10cSrcweir                                 xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k]));
3523cdf0e10cSrcweir                         }
3524cdf0e10cSrcweir                         if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3525cdf0e10cSrcweir                         {
3526cdf0e10cSrcweir                             ::rtl::OUString sName;
3527cdf0e10cSrcweir                             xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName;
3528cdf0e10cSrcweir                             sDefaultName = sName;
3529cdf0e10cSrcweir                             xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName));
3530cdf0e10cSrcweir 
3531cdf0e10cSrcweir                             ReportFormula aFormula( ReportFormula::Field, sName );
3532cdf0e10cSrcweir                             xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) );
3533cdf0e10cSrcweir                         } // if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3534cdf0e10cSrcweir 
3535cdf0e10cSrcweir                         if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3536cdf0e10cSrcweir                             xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3537cdf0e10cSrcweir 
3538cdf0e10cSrcweir                         pObjs[i]->CreateMediator(sal_True);
3539cdf0e10cSrcweir                         // need SectionView from the above or follow Section
3540cdf0e10cSrcweir                         // (getMarkedSection) returns the current Section
3541cdf0e10cSrcweir                         //pSectionViews[i]->InsertObjectAtView(pControl[i],*pPgViews[i],SDRINSERT_ADDMARK);
3542cdf0e10cSrcweir 
3543cdf0e10cSrcweir                         const sal_Int32 nShapeWidth = xShapeProp->getWidth();
3544cdf0e10cSrcweir                         const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3545cdf0e10cSrcweir                         if ( bChangedPos )
3546cdf0e10cSrcweir                             aPos.X = nPaperWidth - nShapeWidth;
3547cdf0e10cSrcweir                         xShapeProp->setPosition(aPos);
3548cdf0e10cSrcweir                         if ( bChangedPos )
3549cdf0e10cSrcweir                             aPos.Y += xShapeProp->getHeight();
3550cdf0e10cSrcweir                         aPos.X += nShapeWidth;
3551cdf0e10cSrcweir 				    }
3552cdf0e10cSrcweir                     ::rtl::OUString sLabel;
3553cdf0e10cSrcweir                     if ( xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
3554cdf0e10cSrcweir                         xField->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
3555cdf0e10cSrcweir 
3556cdf0e10cSrcweir 				    if (pSectionViews[0] != pSectionViews[1] &&
3557cdf0e10cSrcweir 					    nOBJID == OBJ_DLG_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD
3558cdf0e10cSrcweir 				    {
3559cdf0e10cSrcweir 					    // we have two different Views, so set the position x new.
3560cdf0e10cSrcweir 					    // pSectionViews[1].position.x = pSectionViews[0].position.x
3561cdf0e10cSrcweir                         uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3562cdf0e10cSrcweir                         uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3563cdf0e10cSrcweir                         if ( sLabel.getLength() )
3564cdf0e10cSrcweir                             xShapePropTextField->setName(sLabel);
3565cdf0e10cSrcweir 					    awt::Point aPosLabel = xShapePropLabel->getPosition();
3566cdf0e10cSrcweir 					    awt::Point aPosTextField = xShapePropTextField->getPosition();
3567cdf0e10cSrcweir 					    aPosTextField.X = aPosLabel.X;
3568cdf0e10cSrcweir 					    xShapePropTextField->setPosition(aPosTextField);
3569cdf0e10cSrcweir 					    if (bLabelAboveTextField)
3570cdf0e10cSrcweir 					    {
3571cdf0e10cSrcweir 						    // move the label down near the splitter
3572cdf0e10cSrcweir 						    const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection();
3573cdf0e10cSrcweir 						    aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight();
3574cdf0e10cSrcweir 					    }
3575cdf0e10cSrcweir 					    else
3576cdf0e10cSrcweir 					    {
3577cdf0e10cSrcweir 						    // move the label up to the splitter
3578cdf0e10cSrcweir 						    aPosLabel.Y = 0;
3579cdf0e10cSrcweir 					    }
3580cdf0e10cSrcweir 					    xShapePropLabel->setPosition(aPosLabel);
3581cdf0e10cSrcweir 				    }
3582cdf0e10cSrcweir                     OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0]);
3583cdf0e10cSrcweir                     uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
3584cdf0e10cSrcweir                     xShapeProp->setName(xShapeProp->getName() + sDefaultName );
3585cdf0e10cSrcweir 
3586cdf0e10cSrcweir                     for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls
3587cdf0e10cSrcweir                     {
3588cdf0e10cSrcweir                         correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection());
3589cdf0e10cSrcweir                     }
3590cdf0e10cSrcweir 
3591cdf0e10cSrcweir                     if (!bLabelAboveTextField )
3592cdf0e10cSrcweir                     {
3593cdf0e10cSrcweir 						if ( pSectionViews[0] == pSectionViews[1] )
3594cdf0e10cSrcweir                         {
3595cdf0e10cSrcweir 							Rectangle aLabel = getRectangleFromControl(pControl[0]);
3596cdf0e10cSrcweir 							Rectangle aTextfield = getRectangleFromControl(pControl[1]);
3597cdf0e10cSrcweir 
3598cdf0e10cSrcweir 							// create a Union of the given Label and Textfield
3599cdf0e10cSrcweir 							Rectangle aLabelAndTextfield( aLabel );
3600cdf0e10cSrcweir                             aLabelAndTextfield.Union(aTextfield);
3601cdf0e10cSrcweir 
3602cdf0e10cSrcweir 							// check if there exists other fields and if yes, move down
3603cdf0e10cSrcweir                             bool bOverlapping = true;
3604cdf0e10cSrcweir 							bool bHasToMove = false;
3605cdf0e10cSrcweir                             while ( bOverlapping )
3606cdf0e10cSrcweir                             {
3607cdf0e10cSrcweir                                 const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2);
3608cdf0e10cSrcweir                                 bOverlapping = pOverlappedObj != NULL;
3609cdf0e10cSrcweir                                 if ( bOverlapping )
3610cdf0e10cSrcweir                                 {
3611cdf0e10cSrcweir                                     const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
3612cdf0e10cSrcweir                                     aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top());
3613cdf0e10cSrcweir 									bHasToMove = true;
3614cdf0e10cSrcweir                                 }
3615cdf0e10cSrcweir                             }
3616cdf0e10cSrcweir 
3617cdf0e10cSrcweir 							if (bHasToMove)
3618cdf0e10cSrcweir 							{
3619cdf0e10cSrcweir 								// There was a move down, we need to move the Label and the Textfield down
3620cdf0e10cSrcweir 								aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top());
3621cdf0e10cSrcweir 								aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
3622cdf0e10cSrcweir 
3623cdf0e10cSrcweir 								uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3624cdf0e10cSrcweir 								xLabel->setPositionY(aLabel.Top());
3625cdf0e10cSrcweir 
3626cdf0e10cSrcweir 								uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3627cdf0e10cSrcweir 								xTextfield->setPositionY(aTextfield.Top());
3628cdf0e10cSrcweir                         }
3629cdf0e10cSrcweir                     }
3630cdf0e10cSrcweir 						// this should never happen.
3631cdf0e10cSrcweir 						// else
3632cdf0e10cSrcweir 						// {
3633cdf0e10cSrcweir 						//	DBG_ERROR("unhandled case.");
3634cdf0e10cSrcweir 						// }
3635cdf0e10cSrcweir 					}
3636cdf0e10cSrcweir 			    }
3637cdf0e10cSrcweir 		    }
3638cdf0e10cSrcweir 		    else
3639cdf0e10cSrcweir             {
3640cdf0e10cSrcweir 			    for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
3641cdf0e10cSrcweir 				    delete pControl[i];
3642cdf0e10cSrcweir             }
3643cdf0e10cSrcweir         }
3644cdf0e10cSrcweir     }
3645cdf0e10cSrcweir     catch( const Exception& )
3646cdf0e10cSrcweir     {
3647cdf0e10cSrcweir     	DBG_UNHANDLED_EXCEPTION();
3648cdf0e10cSrcweir     }
3649cdf0e10cSrcweir }
3650cdf0e10cSrcweir 
3651cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCurrentSectionView() const3652cdf0e10cSrcweir OSectionView* OReportController::getCurrentSectionView() const
3653cdf0e10cSrcweir {
3654cdf0e10cSrcweir     OSectionView* pSectionView = NULL;
3655cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pSectionWindow = getDesignView()->getMarkedSection();
3656cdf0e10cSrcweir 	if ( pSectionWindow.get() )
3657cdf0e10cSrcweir         pSectionView = &pSectionWindow->getReportSection().getSectionView();
3658cdf0e10cSrcweir     return pSectionView;
3659cdf0e10cSrcweir }
3660cdf0e10cSrcweir // -----------------------------------------------------------------------------
changeZOrder(sal_Int32 _nId)3661cdf0e10cSrcweir void OReportController::changeZOrder(sal_Int32 _nId)
3662cdf0e10cSrcweir {
3663cdf0e10cSrcweir     OSectionView* pSectionView = getCurrentSectionView();
3664cdf0e10cSrcweir     if ( pSectionView )
3665cdf0e10cSrcweir     {
3666cdf0e10cSrcweir         switch(_nId)
3667cdf0e10cSrcweir         {
3668cdf0e10cSrcweir             case SID_FRAME_TO_BOTTOM:
3669cdf0e10cSrcweir                 pSectionView->PutMarkedToBtm();
3670cdf0e10cSrcweir                 break;
3671cdf0e10cSrcweir             case SID_FRAME_TO_TOP:
3672cdf0e10cSrcweir                 pSectionView->PutMarkedToTop();
3673cdf0e10cSrcweir                 break;
3674cdf0e10cSrcweir             case SID_FRAME_DOWN:
3675cdf0e10cSrcweir                 pSectionView->MovMarkedToBtm();
3676cdf0e10cSrcweir                 break;
3677cdf0e10cSrcweir             case SID_FRAME_UP:
3678cdf0e10cSrcweir                 pSectionView->MovMarkedToTop();
3679cdf0e10cSrcweir                 break;
3680cdf0e10cSrcweir 
3681cdf0e10cSrcweir             case SID_OBJECT_HEAVEN:
3682cdf0e10cSrcweir                 pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT );
3683cdf0e10cSrcweir                 break;
3684cdf0e10cSrcweir             case SID_OBJECT_HELL:
3685cdf0e10cSrcweir                 pSectionView->SetMarkedToLayer( RPT_LAYER_BACK );
3686cdf0e10cSrcweir                 break;
3687cdf0e10cSrcweir         }
3688cdf0e10cSrcweir     }
3689cdf0e10cSrcweir }
3690cdf0e10cSrcweir // -----------------------------------------------------------------------------
listen(const bool _bAdd)3691cdf0e10cSrcweir void OReportController::listen(const bool _bAdd)
3692cdf0e10cSrcweir {
3693cdf0e10cSrcweir     const ::rtl::OUString aProps [] = {    PROPERTY_REPORTHEADERON,PROPERTY_REPORTFOOTERON
3694cdf0e10cSrcweir                                             ,PROPERTY_PAGEHEADERON,PROPERTY_PAGEFOOTERON
3695cdf0e10cSrcweir                                             ,PROPERTY_COMMAND, PROPERTY_COMMANDTYPE,PROPERTY_CAPTION
3696cdf0e10cSrcweir     };
3697cdf0e10cSrcweir 
3698cdf0e10cSrcweir     void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const ::rtl::OUString&, const uno::Reference< XPropertyChangeListener >& ) =
3699cdf0e10cSrcweir         _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
3700cdf0e10cSrcweir 
3701cdf0e10cSrcweir     for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i)
3702cdf0e10cSrcweir         (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) );
3703cdf0e10cSrcweir 
3704cdf0e10cSrcweir     OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3705cdf0e10cSrcweir     uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
3706cdf0e10cSrcweir     uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
3707cdf0e10cSrcweir     const beans::Property* pIter = aSeq.getConstArray();
3708cdf0e10cSrcweir     const beans::Property* pEnd	  = pIter + aSeq.getLength();
3709cdf0e10cSrcweir     const ::rtl::OUString* pPropsBegin = &aProps[0];
3710cdf0e10cSrcweir     const ::rtl::OUString* pPropsEnd   = pPropsBegin + (sizeof(aProps)/sizeof(aProps[0])) - 3;
3711cdf0e10cSrcweir     for(;pIter != pEnd;++pIter)
3712cdf0e10cSrcweir     {
3713cdf0e10cSrcweir         if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd )
3714cdf0e10cSrcweir             (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo );
3715cdf0e10cSrcweir     }
3716cdf0e10cSrcweir 
3717cdf0e10cSrcweir     // Add Listeners to UndoEnvironment
3718cdf0e10cSrcweir     void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) =
3719cdf0e10cSrcweir         _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement;
3720cdf0e10cSrcweir 
3721cdf0e10cSrcweir     (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() );
3722cdf0e10cSrcweir     (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() );
3723cdf0e10cSrcweir 
3724cdf0e10cSrcweir     // Add Listeners to ReportControllerObserver
3725cdf0e10cSrcweir     OXReportControllerObserver& rObserver = *m_pReportControllerObserver;
3726cdf0e10cSrcweir     // void (OXReportControllerObserver::*pObserverFunction)( const uno::Reference< uno::XInterface >& ) =
3727cdf0e10cSrcweir     //     _bAdd ? &OXReportControllerObserver::AddElement : &OXReportControllerObserver::RemoveElement;
3728cdf0e10cSrcweir 
3729cdf0e10cSrcweir     // (rObserver.*pObserverFunction)( m_xReportDefinition->getStyleFamilies() );
3730cdf0e10cSrcweir     // (rObserver.*pObserverFunction)( m_xReportDefinition->getFunctions() );
3731cdf0e10cSrcweir 
3732cdf0e10cSrcweir     if ( m_xReportDefinition->getPageHeaderOn() && _bAdd )
3733cdf0e10cSrcweir     {
3734cdf0e10cSrcweir         getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER);
3735cdf0e10cSrcweir         rObserver.AddSection(m_xReportDefinition->getPageHeader());
3736cdf0e10cSrcweir     }
3737cdf0e10cSrcweir 	if ( m_xReportDefinition->getReportHeaderOn() && _bAdd )
3738cdf0e10cSrcweir     {
3739cdf0e10cSrcweir         getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER);
3740cdf0e10cSrcweir         rObserver.AddSection(m_xReportDefinition->getReportHeader());
3741cdf0e10cSrcweir     }
3742cdf0e10cSrcweir 
3743cdf0e10cSrcweir 	uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3744cdf0e10cSrcweir 	const sal_Int32 nCount = xGroups->getCount();
3745cdf0e10cSrcweir     _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv);
3746cdf0e10cSrcweir     _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver);
3747cdf0e10cSrcweir 
3748cdf0e10cSrcweir 	for (sal_Int32 i=0;i<nCount ; ++i)
3749cdf0e10cSrcweir 	{
3750cdf0e10cSrcweir 		uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
3751cdf0e10cSrcweir         (xGroup.get()->*pPropertyListenerAction)( PROPERTY_HEADERON, static_cast< XPropertyChangeListener* >( this ) );
3752cdf0e10cSrcweir         (xGroup.get()->*pPropertyListenerAction)( PROPERTY_FOOTERON, static_cast< XPropertyChangeListener* >( this ) );
3753cdf0e10cSrcweir 
3754cdf0e10cSrcweir         (rUndoEnv.*pElementUndoFunction)( xGroup );
3755cdf0e10cSrcweir         (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() );
3756cdf0e10cSrcweir 		if ( xGroup->getHeaderOn() && _bAdd )
3757cdf0e10cSrcweir         {
3758cdf0e10cSrcweir 			getDesignView()->addSection(xGroup->getHeader(),DBGROUPHEADER);
3759cdf0e10cSrcweir             rObserver.AddSection(xGroup->getHeader());
3760cdf0e10cSrcweir         }
3761cdf0e10cSrcweir 	} // for (sal_Int32 i=0;i<nCount ; ++i)
3762cdf0e10cSrcweir 
3763cdf0e10cSrcweir     if ( _bAdd )
3764cdf0e10cSrcweir     {
3765cdf0e10cSrcweir         getDesignView()->addSection(m_xReportDefinition->getDetail(),DBDETAIL);
3766cdf0e10cSrcweir         rObserver.AddSection(m_xReportDefinition->getDetail());
3767cdf0e10cSrcweir 
3768cdf0e10cSrcweir 	    for (sal_Int32 i=nCount;i > 0 ; --i)
3769cdf0e10cSrcweir 	    {
3770cdf0e10cSrcweir 		    uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY);
3771cdf0e10cSrcweir 		    if ( xGroup->getFooterOn() )
3772cdf0e10cSrcweir             {
3773cdf0e10cSrcweir                 getDesignView()->addSection(xGroup->getFooter(),DBGROUPFOOTER);
3774cdf0e10cSrcweir                 rObserver.AddSection(xGroup->getFooter());
3775cdf0e10cSrcweir 	        }
3776cdf0e10cSrcweir 	    }
3777cdf0e10cSrcweir         if ( m_xReportDefinition->getReportFooterOn() )
3778cdf0e10cSrcweir         {
3779cdf0e10cSrcweir 		    getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER);
3780cdf0e10cSrcweir             rObserver.AddSection(m_xReportDefinition->getReportFooter());
3781cdf0e10cSrcweir         }
3782cdf0e10cSrcweir 	    if ( m_xReportDefinition->getPageFooterOn())
3783cdf0e10cSrcweir         {
3784cdf0e10cSrcweir 		    getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
3785cdf0e10cSrcweir             rObserver.AddSection(m_xReportDefinition->getPageFooter());
3786cdf0e10cSrcweir         }
3787cdf0e10cSrcweir 
3788cdf0e10cSrcweir         xGroups->addContainerListener(static_cast<XContainerListener*>(this));
3789cdf0e10cSrcweir         m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this));
3790cdf0e10cSrcweir     }
3791cdf0e10cSrcweir     else /* ! _bAdd */
3792cdf0e10cSrcweir     {
3793cdf0e10cSrcweir         rObserver.RemoveSection(m_xReportDefinition->getDetail());
3794cdf0e10cSrcweir         xGroups->removeContainerListener(static_cast<XContainerListener*>(this));
3795cdf0e10cSrcweir         m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this));
3796cdf0e10cSrcweir         m_aReportModel->detachController();
3797cdf0e10cSrcweir     }
3798cdf0e10cSrcweir }
3799cdf0e10cSrcweir // -----------------------------------------------------------------------------
switchReportSection(const sal_Int16 _nId)3800cdf0e10cSrcweir void OReportController::switchReportSection(const sal_Int16 _nId)
3801cdf0e10cSrcweir {
3802cdf0e10cSrcweir     OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!");
3803cdf0e10cSrcweir 
3804cdf0e10cSrcweir 	if ( m_xReportDefinition.is() )
3805cdf0e10cSrcweir 	{
3806cdf0e10cSrcweir 		const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3807cdf0e10cSrcweir 		const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn();
3808cdf0e10cSrcweir 
3809cdf0e10cSrcweir         ::boost::scoped_ptr< UndoContext > pUndoContext;
3810cdf0e10cSrcweir 		if ( SID_REPORTHEADERFOOTER == _nId )
3811cdf0e10cSrcweir 		{
3812cdf0e10cSrcweir 			const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3813cdf0e10cSrcweir             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3814cdf0e10cSrcweir 
3815cdf0e10cSrcweir 			addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO
3816cdf0e10cSrcweir 															,::std::mem_fun(&OReportHelper::getReportHeader)
3817cdf0e10cSrcweir 															,m_xReportDefinition
3818cdf0e10cSrcweir 															,bSwitchOn ? Inserted : Removed
3819cdf0e10cSrcweir 															,0
3820cdf0e10cSrcweir 															));
3821cdf0e10cSrcweir 
3822cdf0e10cSrcweir 			addUndoAction(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO
3823cdf0e10cSrcweir 															,::std::mem_fun(&OReportHelper::getReportFooter)
3824cdf0e10cSrcweir 															,m_xReportDefinition
3825cdf0e10cSrcweir 															,bSwitchOn ? Inserted : Removed
3826cdf0e10cSrcweir 															,0
3827cdf0e10cSrcweir 															));
3828cdf0e10cSrcweir 		}
3829cdf0e10cSrcweir 
3830cdf0e10cSrcweir 		switch( _nId )
3831cdf0e10cSrcweir 		{
3832cdf0e10cSrcweir 			case SID_REPORTHEADER_WITHOUT_UNDO:
3833cdf0e10cSrcweir 				m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3834cdf0e10cSrcweir 				break;
3835cdf0e10cSrcweir 			case SID_REPORTFOOTER_WITHOUT_UNDO:
3836cdf0e10cSrcweir 				m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() );
3837cdf0e10cSrcweir 				break;
3838cdf0e10cSrcweir 			case SID_REPORTHEADERFOOTER:
3839cdf0e10cSrcweir 				m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3840cdf0e10cSrcweir 				m_xReportDefinition->setReportFooterOn( bSwitchOn );
3841cdf0e10cSrcweir 				break;
3842cdf0e10cSrcweir 		}
3843cdf0e10cSrcweir 
3844cdf0e10cSrcweir         if ( SID_REPORTHEADERFOOTER == _nId )
3845cdf0e10cSrcweir             pUndoContext.reset();
3846cdf0e10cSrcweir 		getView()->Resize();
3847cdf0e10cSrcweir 	}
3848cdf0e10cSrcweir }
3849cdf0e10cSrcweir // -----------------------------------------------------------------------------
switchPageSection(const sal_Int16 _nId)3850cdf0e10cSrcweir void OReportController::switchPageSection(const sal_Int16 _nId)
3851cdf0e10cSrcweir {
3852cdf0e10cSrcweir     OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!");
3853cdf0e10cSrcweir     if ( m_xReportDefinition.is() )
3854cdf0e10cSrcweir 	{
3855cdf0e10cSrcweir 		const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3856cdf0e10cSrcweir 		const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn();
3857cdf0e10cSrcweir 
3858cdf0e10cSrcweir         ::boost::scoped_ptr< UndoContext > pUndoContext;
3859cdf0e10cSrcweir 		if ( SID_PAGEHEADERFOOTER == _nId )
3860cdf0e10cSrcweir 		{
3861cdf0e10cSrcweir 			const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3862cdf0e10cSrcweir             pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3863cdf0e10cSrcweir 
3864cdf0e10cSrcweir 			addUndoAction(new OReportSectionUndo(*m_aReportModel
3865cdf0e10cSrcweir 															,SID_PAGEHEADER_WITHOUT_UNDO
3866cdf0e10cSrcweir 															,::std::mem_fun(&OReportHelper::getPageHeader)
3867cdf0e10cSrcweir 															,m_xReportDefinition
3868cdf0e10cSrcweir 															,bSwitchOn ? Inserted : Removed
3869cdf0e10cSrcweir 															,0
3870cdf0e10cSrcweir 															));
3871cdf0e10cSrcweir 
3872cdf0e10cSrcweir 			addUndoAction(new OReportSectionUndo(*m_aReportModel
3873cdf0e10cSrcweir 															,SID_PAGEFOOTER_WITHOUT_UNDO
3874cdf0e10cSrcweir 															,::std::mem_fun(&OReportHelper::getPageFooter)
3875cdf0e10cSrcweir 															,m_xReportDefinition
3876cdf0e10cSrcweir 															,bSwitchOn ? Inserted : Removed
3877cdf0e10cSrcweir 															,0
3878cdf0e10cSrcweir 															));
3879cdf0e10cSrcweir 		} // if ( SID_PAGEHEADERFOOTER == _nId )
3880cdf0e10cSrcweir 		switch( _nId )
3881cdf0e10cSrcweir 		{
3882cdf0e10cSrcweir 			case SID_PAGEHEADER_WITHOUT_UNDO:
3883cdf0e10cSrcweir 				m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3884cdf0e10cSrcweir 				break;
3885cdf0e10cSrcweir 			case SID_PAGEFOOTER_WITHOUT_UNDO:
3886cdf0e10cSrcweir 				m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() );
3887cdf0e10cSrcweir 				break;
3888cdf0e10cSrcweir 			case SID_PAGEHEADERFOOTER:
3889cdf0e10cSrcweir 				m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3890cdf0e10cSrcweir 				m_xReportDefinition->setPageFooterOn( bSwitchOn );
3891cdf0e10cSrcweir 				break;
3892cdf0e10cSrcweir 		}
3893cdf0e10cSrcweir         if ( SID_PAGEHEADERFOOTER == _nId )
3894cdf0e10cSrcweir             pUndoContext.reset();
3895cdf0e10cSrcweir 		getView()->Resize();
3896cdf0e10cSrcweir 	}
3897cdf0e10cSrcweir }
3898cdf0e10cSrcweir // -----------------------------------------------------------------------------
modifyGroup(const bool _bAppend,const Sequence<PropertyValue> & _aArgs)3899cdf0e10cSrcweir void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs)
3900cdf0e10cSrcweir {
3901cdf0e10cSrcweir     if ( !m_xReportDefinition.is() )
3902cdf0e10cSrcweir         return;
3903cdf0e10cSrcweir 
3904cdf0e10cSrcweir     try
3905cdf0e10cSrcweir     {
3906cdf0e10cSrcweir 		const SequenceAsHashMap aMap( _aArgs );
3907cdf0e10cSrcweir 		uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() );
3908cdf0e10cSrcweir         if ( !xGroup.is() )
3909cdf0e10cSrcweir             return;
3910cdf0e10cSrcweir 
3911cdf0e10cSrcweir         OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3912cdf0e10cSrcweir 		uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3913cdf0e10cSrcweir 		if ( _bAppend )
3914cdf0e10cSrcweir 		{
3915cdf0e10cSrcweir 			const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() );
3916cdf0e10cSrcweir 			xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) );
3917cdf0e10cSrcweir             rUndoEnv.AddElement( xGroup->getFunctions() );
3918cdf0e10cSrcweir 		}
3919cdf0e10cSrcweir 
3920cdf0e10cSrcweir 		addUndoAction( new OGroupUndo(
3921cdf0e10cSrcweir             *m_aReportModel,
3922cdf0e10cSrcweir             _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
3923cdf0e10cSrcweir             _bAppend ? Inserted : Removed,
3924cdf0e10cSrcweir             xGroup,
3925cdf0e10cSrcweir             m_xReportDefinition
3926cdf0e10cSrcweir         ) );
3927cdf0e10cSrcweir 
3928cdf0e10cSrcweir 		if ( !_bAppend )
3929cdf0e10cSrcweir 		{
3930cdf0e10cSrcweir             rUndoEnv.RemoveElement( xGroup->getFunctions() );
3931cdf0e10cSrcweir 			const sal_Int32 nPos = getGroupPosition( xGroup );
3932cdf0e10cSrcweir             const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3933cdf0e10cSrcweir 			xGroups->removeByIndex( nPos );
3934cdf0e10cSrcweir 		}
3935cdf0e10cSrcweir     }
3936cdf0e10cSrcweir     catch( const Exception& )
3937cdf0e10cSrcweir     {
3938cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
3939cdf0e10cSrcweir     }
3940cdf0e10cSrcweir }
3941cdf0e10cSrcweir 
3942cdf0e10cSrcweir // -----------------------------------------------------------------------------
createGroupSection(const bool _bUndo,const bool _bHeader,const Sequence<PropertyValue> & _aArgs)3943cdf0e10cSrcweir void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs)
3944cdf0e10cSrcweir {
3945cdf0e10cSrcweir     if ( m_xReportDefinition.is() )
3946cdf0e10cSrcweir 	{
3947cdf0e10cSrcweir 		const SequenceAsHashMap aMap(_aArgs);
3948cdf0e10cSrcweir         const sal_Bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? PROPERTY_HEADERON : PROPERTY_FOOTERON,sal_False);
3949cdf0e10cSrcweir 		uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>());
3950cdf0e10cSrcweir 		if ( xGroup.is() )
3951cdf0e10cSrcweir 		{
3952cdf0e10cSrcweir             const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
3953cdf0e10cSrcweir 			if ( _bUndo )
3954cdf0e10cSrcweir 				addUndoAction(new OGroupSectionUndo(*m_aReportModel
3955cdf0e10cSrcweir                                                                 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
3956cdf0e10cSrcweir                                                                 ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter)
3957cdf0e10cSrcweir 																,xGroup
3958cdf0e10cSrcweir 																,bSwitchOn ? Inserted : Removed
3959cdf0e10cSrcweir                                                                 , ( _bHeader ?
3960cdf0e10cSrcweir 																        (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER)
3961cdf0e10cSrcweir                                                                        :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER)
3962cdf0e10cSrcweir                                                                   )
3963cdf0e10cSrcweir 																));
3964cdf0e10cSrcweir 
3965cdf0e10cSrcweir             if ( _bHeader )
3966cdf0e10cSrcweir 			    xGroup->setHeaderOn( bSwitchOn );
3967cdf0e10cSrcweir             else
3968cdf0e10cSrcweir                 xGroup->setFooterOn( bSwitchOn );
3969cdf0e10cSrcweir 		}
3970cdf0e10cSrcweir 	}
3971cdf0e10cSrcweir }
3972cdf0e10cSrcweir // -----------------------------------------------------------------------------
collapseSection(const bool _bCollapse)3973cdf0e10cSrcweir void OReportController::collapseSection(const bool _bCollapse)
3974cdf0e10cSrcweir {
3975cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
3976cdf0e10cSrcweir     if ( pSection )
3977cdf0e10cSrcweir     {
3978cdf0e10cSrcweir         pSection->setCollapsed(_bCollapse);
3979cdf0e10cSrcweir     }
3980cdf0e10cSrcweir }
3981cdf0e10cSrcweir // -----------------------------------------------------------------------------
markSection(const bool _bNext)3982cdf0e10cSrcweir void OReportController::markSection(const bool _bNext)
3983cdf0e10cSrcweir {
3984cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pSection = getDesignView()->getMarkedSection();
3985cdf0e10cSrcweir     if ( pSection )
3986cdf0e10cSrcweir     {
3987cdf0e10cSrcweir         ::boost::shared_ptr<OSectionWindow> pPrevSection = getDesignView()->getMarkedSection(_bNext ? POST : PREVIOUS);
3988cdf0e10cSrcweir         if ( pPrevSection != pSection && pPrevSection )
3989cdf0e10cSrcweir             select(uno::makeAny(pPrevSection->getReportSection().getSection()));
3990cdf0e10cSrcweir         else
3991cdf0e10cSrcweir             select(uno::makeAny(m_xReportDefinition));
3992cdf0e10cSrcweir     }
3993cdf0e10cSrcweir     else
3994cdf0e10cSrcweir     {
3995cdf0e10cSrcweir         getDesignView()->markSection(_bNext ? 0 : getDesignView()->getSectionCount() - 1);
3996cdf0e10cSrcweir         pSection = getDesignView()->getMarkedSection();
3997cdf0e10cSrcweir         if ( pSection )
3998cdf0e10cSrcweir             select(uno::makeAny(pSection->getReportSection().getSection()));
3999cdf0e10cSrcweir     }
4000cdf0e10cSrcweir }
4001cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDefaultControl(const uno::Sequence<beans::PropertyValue> & _aArgs)4002cdf0e10cSrcweir void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs)
4003cdf0e10cSrcweir {
4004cdf0e10cSrcweir     uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
4005cdf0e10cSrcweir     if ( !xSection.is() )
4006cdf0e10cSrcweir         xSection = m_xReportDefinition->getDetail();
4007cdf0e10cSrcweir 
4008cdf0e10cSrcweir     if ( xSection.is() )
4009cdf0e10cSrcweir     {
4010cdf0e10cSrcweir         const ::rtl::OUString sKeyModifier(RTL_CONSTASCII_USTRINGPARAM("KeyModifier"));
4011cdf0e10cSrcweir         const beans::PropertyValue* pIter = _aArgs.getConstArray();
4012cdf0e10cSrcweir         const beans::PropertyValue* pEnd  = pIter + _aArgs.getLength();
4013cdf0e10cSrcweir         const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyValueCompare(),boost::cref(sKeyModifier)));
4014cdf0e10cSrcweir         sal_Int16 nKeyModifier = 0;
4015cdf0e10cSrcweir         if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) )
4016cdf0e10cSrcweir         {
4017cdf0e10cSrcweir             Sequence< PropertyValue > aCreateArgs;
4018cdf0e10cSrcweir             getDesignView()->unmarkAllObjects(NULL);
4019cdf0e10cSrcweir             createControl(aCreateArgs,xSection,::rtl::OUString(),getDesignView()->GetInsertObj());
4020cdf0e10cSrcweir         }
4021cdf0e10cSrcweir     }
4022cdf0e10cSrcweir }
4023cdf0e10cSrcweir // -----------------------------------------------------------------------------
getReportNumberFormatter() const4024cdf0e10cSrcweir uno::Reference< util::XNumberFormatter > OReportController::getReportNumberFormatter() const
4025cdf0e10cSrcweir {
4026cdf0e10cSrcweir     return m_xFormatter;
4027cdf0e10cSrcweir }
4028cdf0e10cSrcweir // -----------------------------------------------------------------------------
checkChartEnabled()4029cdf0e10cSrcweir void OReportController::checkChartEnabled()
4030cdf0e10cSrcweir {
4031cdf0e10cSrcweir     if ( !m_bChartEnabledAsked )
4032cdf0e10cSrcweir     {
4033cdf0e10cSrcweir         m_bChartEnabledAsked = true;
4034cdf0e10cSrcweir         const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign" ) );
4035cdf0e10cSrcweir         const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "UserData/Chart" ) );
4036cdf0e10cSrcweir 
4037cdf0e10cSrcweir         try
4038cdf0e10cSrcweir         {
4039cdf0e10cSrcweir             ::utl::OConfigurationTreeRoot aConfiguration(
4040cdf0e10cSrcweir                 ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xServiceFactory, sConfigName ) );
4041cdf0e10cSrcweir 
4042cdf0e10cSrcweir             sal_Bool bChartEnabled = sal_False;
4043cdf0e10cSrcweir             if ( aConfiguration.hasByHierarchicalName(sPropertyName) )
4044cdf0e10cSrcweir                 aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled;
4045cdf0e10cSrcweir             m_bChartEnabled = bChartEnabled;
4046cdf0e10cSrcweir         }
4047cdf0e10cSrcweir         catch(const Exception&)
4048cdf0e10cSrcweir         {
4049cdf0e10cSrcweir         }
4050cdf0e10cSrcweir     }
4051cdf0e10cSrcweir }
4052cdf0e10cSrcweir // -----------------------------------------------------------------------------
4053cdf0e10cSrcweir 
4054cdf0e10cSrcweir // css.frame.XTitle
getTitle()4055cdf0e10cSrcweir ::rtl::OUString SAL_CALL OReportController::getTitle()
4056cdf0e10cSrcweir     throw (uno::RuntimeException)
4057cdf0e10cSrcweir {
4058cdf0e10cSrcweir     vos::OGuard aSolarGuard( Application::GetSolarMutex() );
4059cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
4060cdf0e10cSrcweir 
4061cdf0e10cSrcweir     uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW);
4062cdf0e10cSrcweir 
4063cdf0e10cSrcweir     return xTitle->getTitle ();
4064cdf0e10cSrcweir }
4065cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertyDefaultByHandle(sal_Int32,Any & _rDefault) const4066cdf0e10cSrcweir void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
4067cdf0e10cSrcweir {
4068cdf0e10cSrcweir 	_rDefault <<= sal_Int16(100);
4069cdf0e10cSrcweir }
4070cdf0e10cSrcweir // -----------------------------------------------------------------------------
4071cdf0e10cSrcweir // comphelper::OPropertyArrayUsageHelper
createArrayHelper() const4072cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const
4073cdf0e10cSrcweir {
4074cdf0e10cSrcweir 	Sequence< Property > aProps;
4075cdf0e10cSrcweir 	describeProperties(aProps);
4076cdf0e10cSrcweir 	return new ::cppu::OPropertyArrayHelper(aProps);
4077cdf0e10cSrcweir }
4078cdf0e10cSrcweir // -------------------------------------------------------------------------
4079cdf0e10cSrcweir 
4080cdf0e10cSrcweir // cppu::OPropertySetHelper
getInfoHelper()4081cdf0e10cSrcweir ::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper()
4082cdf0e10cSrcweir {
4083cdf0e10cSrcweir 	typedef ::comphelper::OPropertyArrayUsageHelper<OReportController_BASE> OReportController_PROP;
4084cdf0e10cSrcweir 	return *OReportController_PROP::getArrayHelper();
4085cdf0e10cSrcweir }
4086cdf0e10cSrcweir // -----------------------------------------------------------------------------
setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any & _aValue)4087cdf0e10cSrcweir void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue) throw (Exception)
4088cdf0e10cSrcweir {
4089cdf0e10cSrcweir     if ( _nHandle == PROPERTY_ID_ZOOMVALUE )
4090cdf0e10cSrcweir     {
4091cdf0e10cSrcweir         _aValue >>= m_nZoomValue;
4092cdf0e10cSrcweir         impl_zoom_nothrow();
4093cdf0e10cSrcweir     }
4094cdf0e10cSrcweir }
setMode(const::rtl::OUString & aMode)4095cdf0e10cSrcweir void SAL_CALL OReportController::setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException)
4096cdf0e10cSrcweir {
4097cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
4098cdf0e10cSrcweir 	m_sMode = aMode;
4099cdf0e10cSrcweir }
getMode()4100cdf0e10cSrcweir ::rtl::OUString SAL_CALL OReportController::getMode(  ) throw (::com::sun::star::uno::RuntimeException)
4101cdf0e10cSrcweir {
4102cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
4103cdf0e10cSrcweir 	return m_sMode;
4104cdf0e10cSrcweir }
getSupportedModes()4105cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OReportController::getSupportedModes(  ) throw (::com::sun::star::uno::RuntimeException)
4106cdf0e10cSrcweir {
4107cdf0e10cSrcweir 	static ::rtl::OUString s_sModes[] = { ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("remote")),
4108cdf0e10cSrcweir 										  ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal")) };
4109cdf0e10cSrcweir 	return uno::Sequence< ::rtl::OUString> (&s_sModes[0],sizeof(s_sModes)/sizeof(s_sModes[0]));
4110cdf0e10cSrcweir }
supportsMode(const::rtl::OUString & aMode)4111cdf0e10cSrcweir ::sal_Bool SAL_CALL OReportController::supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException)
4112cdf0e10cSrcweir {
4113cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString> aModes = getSupportedModes();
4114cdf0e10cSrcweir 	const ::rtl::OUString* pIter = aModes.getConstArray();
4115cdf0e10cSrcweir     const ::rtl::OUString* pEnd  = pIter + aModes.getLength();
4116cdf0e10cSrcweir     for(;pIter != pEnd;++pIter)
4117cdf0e10cSrcweir     {
4118cdf0e10cSrcweir 		if ( pIter->equals(aMode ) )
4119cdf0e10cSrcweir 			break;
4120cdf0e10cSrcweir 	}
4121cdf0e10cSrcweir 	return pIter != pEnd;
4122cdf0e10cSrcweir }
4123cdf0e10cSrcweir // -----------------------------------------------------------------------------
isUiVisible() const4124cdf0e10cSrcweir bool OReportController::isUiVisible() const
4125cdf0e10cSrcweir {
4126cdf0e10cSrcweir     return !m_sMode.equalsAscii("remote");
4127cdf0e10cSrcweir }
4128cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_fillState_nothrow(const::rtl::OUString & _sProperty,dbaui::FeatureState & _rState) const4129cdf0e10cSrcweir void OReportController::impl_fillState_nothrow(const ::rtl::OUString& _sProperty,dbaui::FeatureState& _rState) const
4130cdf0e10cSrcweir {
4131cdf0e10cSrcweir     _rState.bEnabled = isEditable();
4132cdf0e10cSrcweir 	if ( _rState.bEnabled )
4133cdf0e10cSrcweir     {
4134cdf0e10cSrcweir         ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4135cdf0e10cSrcweir         getDesignView()->fillControlModelSelection(aSelection);
4136cdf0e10cSrcweir         _rState.bEnabled = !aSelection.empty();
4137cdf0e10cSrcweir         if ( _rState.bEnabled )
4138cdf0e10cSrcweir         {
4139cdf0e10cSrcweir             uno::Any aTemp;
4140cdf0e10cSrcweir             ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
4141cdf0e10cSrcweir             for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter)
4142cdf0e10cSrcweir             {
4143cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY);
4144cdf0e10cSrcweir                 try
4145cdf0e10cSrcweir                 {
4146cdf0e10cSrcweir                     uno::Any aTemp2 = xProp->getPropertyValue(_sProperty);
4147cdf0e10cSrcweir                     if ( aIter == aSelection.begin() )
4148cdf0e10cSrcweir                     {
4149cdf0e10cSrcweir                         aTemp = aTemp2;
4150cdf0e10cSrcweir                     }
4151cdf0e10cSrcweir                     else if ( !comphelper::compare(aTemp,aTemp2) )
4152cdf0e10cSrcweir                         break;
4153cdf0e10cSrcweir                 }
4154cdf0e10cSrcweir                 catch(beans::UnknownPropertyException&)
4155cdf0e10cSrcweir                 {
4156cdf0e10cSrcweir                     _rState.bEnabled = sal_False;
4157cdf0e10cSrcweir                 }
4158cdf0e10cSrcweir             } // for(; aIter != aSelection.end();++aIter)
4159cdf0e10cSrcweir             if ( aIter == aSelection.end() )
4160cdf0e10cSrcweir                 _rState.aValue = aTemp;
4161cdf0e10cSrcweir         }
4162cdf0e10cSrcweir     } // if ( _rState.bEnabled )
4163cdf0e10cSrcweir }
4164cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_zoom_nothrow()4165cdf0e10cSrcweir void OReportController::impl_zoom_nothrow()
4166cdf0e10cSrcweir {
4167cdf0e10cSrcweir     Fraction aZoom(m_nZoomValue,100);
4168cdf0e10cSrcweir     setZoomFactor( aZoom,*getDesignView() );
4169cdf0e10cSrcweir     getDesignView()->zoom(aZoom);
4170cdf0e10cSrcweir     // TRY
4171cdf0e10cSrcweir     /*getDesignView()->Invalidate(INVALIDATE_NOCHILDREN);*/
4172cdf0e10cSrcweir     InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(),sal_True);
4173cdf0e10cSrcweir     InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(),sal_True);
4174cdf0e10cSrcweir }
4175cdf0e10cSrcweir // -----------------------------------------------------------------------------
isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference<report::XReportControlFormat> & _xReportControlFormat) const4176cdf0e10cSrcweir sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat) const
4177cdf0e10cSrcweir {
4178cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
4179cdf0e10cSrcweir     if ( _xReportControlFormat.is() && !uno::Reference< report::XFixedLine>(_xReportControlFormat,uno::UNO_QUERY).is() ) // this command is really often called so we nedd a short cut here
4180cdf0e10cSrcweir 	{
4181cdf0e10cSrcweir 		try
4182cdf0e10cSrcweir 		{
4183cdf0e10cSrcweir 			const awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
4184cdf0e10cSrcweir 
4185cdf0e10cSrcweir 			switch(_nCommand)
4186cdf0e10cSrcweir 			{
4187cdf0e10cSrcweir 				case SID_ATTR_CHAR_WEIGHT:
4188cdf0e10cSrcweir 					bRet = awt::FontWeight::BOLD == aFontDescriptor.Weight;
4189cdf0e10cSrcweir 					break;
4190cdf0e10cSrcweir 				case SID_ATTR_CHAR_POSTURE:
4191cdf0e10cSrcweir 					bRet = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
4192cdf0e10cSrcweir 					break;
4193cdf0e10cSrcweir 				case SID_ATTR_CHAR_UNDERLINE:
4194cdf0e10cSrcweir 					bRet = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
4195cdf0e10cSrcweir 					break;
4196cdf0e10cSrcweir 				default:
4197cdf0e10cSrcweir 					;
4198cdf0e10cSrcweir 			} // switch(_nCommand)
4199cdf0e10cSrcweir 		}
4200cdf0e10cSrcweir 		catch(uno::Exception&)
4201cdf0e10cSrcweir 		{
4202cdf0e10cSrcweir 		}
4203cdf0e10cSrcweir 	}
4204cdf0e10cSrcweir 	return bRet;
4205cdf0e10cSrcweir }
4206cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const::rtl::OUString & _sProperty,const uno::Any & _aValue,const Sequence<PropertyValue> & _aArgs)4207cdf0e10cSrcweir bool OReportController::impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const ::rtl::OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs)
4208cdf0e10cSrcweir {
4209cdf0e10cSrcweir     ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4210cdf0e10cSrcweir     uno::Reference< awt::XWindow> xWindow;
4211cdf0e10cSrcweir     lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection );
4212cdf0e10cSrcweir     ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
4213cdf0e10cSrcweir 
4214cdf0e10cSrcweir     const String sUndoAction = String( ModuleRes( _nUndoResId ) );
4215cdf0e10cSrcweir     UndoContext aUndoContext( getUndoManager(), sUndoAction );
4216cdf0e10cSrcweir 
4217cdf0e10cSrcweir     for(;  aIter != aSelection.end();++aIter)
4218cdf0e10cSrcweir     {
4219cdf0e10cSrcweir         const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY);
4220cdf0e10cSrcweir         if ( xControlModel.is() )
4221cdf0e10cSrcweir             xControlModel->setPropertyValue(_sProperty,_aValue);
4222cdf0e10cSrcweir     }
4223cdf0e10cSrcweir 
4224cdf0e10cSrcweir     return !aSelection.empty();
4225cdf0e10cSrcweir }
4226cdf0e10cSrcweir // -----------------------------------------------------------------------------
impl_fillCustomShapeState_nothrow(const char * _pCustomShapeType,dbaui::FeatureState & _rState) const4227cdf0e10cSrcweir void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomShapeType,dbaui::FeatureState& _rState) const
4228cdf0e10cSrcweir {
4229cdf0e10cSrcweir     _rState.bEnabled = isEditable();
4230cdf0e10cSrcweir 	_rState.bChecked = getDesignView()->GetInsertObj() == OBJ_CUSTOMSHAPE && getDesignView()->GetInsertObjString().compareToAscii(_pCustomShapeType) == 0;
4231cdf0e10cSrcweir }
4232cdf0e10cSrcweir 
4233cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSectionWindow(const::com::sun::star::uno::Reference<::com::sun::star::report::XSection> & _xSection) const4234cdf0e10cSrcweir ::boost::shared_ptr<OSectionWindow> OReportController::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const
4235cdf0e10cSrcweir {
4236cdf0e10cSrcweir     if ( getDesignView() )
4237cdf0e10cSrcweir     {
4238cdf0e10cSrcweir         return  getDesignView()->getSectionWindow(_xSection);
4239cdf0e10cSrcweir     }
4240cdf0e10cSrcweir 
4241cdf0e10cSrcweir     // throw NullPointerException?
4242cdf0e10cSrcweir     ::boost::shared_ptr<OSectionWindow> pEmpty;
4243cdf0e10cSrcweir     return pEmpty;
4244cdf0e10cSrcweir }
4245cdf0e10cSrcweir 
4246cdf0e10cSrcweir 
4247cdf0e10cSrcweir // -----------------------------------------------------------------------------
openZoomDialog()4248cdf0e10cSrcweir void OReportController::openZoomDialog()
4249cdf0e10cSrcweir {
4250cdf0e10cSrcweir     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
4251cdf0e10cSrcweir 	if ( pFact )
4252cdf0e10cSrcweir 	{
4253cdf0e10cSrcweir         static SfxItemInfo aItemInfos[] =
4254cdf0e10cSrcweir 	    {
4255cdf0e10cSrcweir 		    { SID_ATTR_ZOOM, SFX_ITEM_POOLABLE }
4256cdf0e10cSrcweir         };
4257cdf0e10cSrcweir         SfxPoolItem* pDefaults[] =
4258cdf0e10cSrcweir 	    {
4259cdf0e10cSrcweir 		    new SvxZoomItem()
4260cdf0e10cSrcweir         };
4261cdf0e10cSrcweir         static sal_uInt16 pRanges[] =
4262cdf0e10cSrcweir 	    {
4263cdf0e10cSrcweir 		    SID_ATTR_ZOOM,SID_ATTR_ZOOM,
4264cdf0e10cSrcweir             0
4265cdf0e10cSrcweir 	    };
4266cdf0e10cSrcweir         SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ZoomProperties"), SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, pDefaults) );
4267cdf0e10cSrcweir         pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );	// ripped, don't understand why
4268cdf0e10cSrcweir 		pPool->FreezeIdRanges();						// the same
4269cdf0e10cSrcweir         try
4270cdf0e10cSrcweir         {
4271cdf0e10cSrcweir 		    ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
4272cdf0e10cSrcweir 		    // fill it
4273cdf0e10cSrcweir             SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
4274cdf0e10cSrcweir             aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH);
4275cdf0e10cSrcweir             pDescriptor->Put(aZoomItem);
4276cdf0e10cSrcweir 
4277cdf0e10cSrcweir             ::std::auto_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get()) );
4278cdf0e10cSrcweir 		    pDlg->SetLimits( 20, 400 );
4279cdf0e10cSrcweir 		    bool bCancel = ( RET_CANCEL == pDlg->Execute() );
4280cdf0e10cSrcweir 
4281cdf0e10cSrcweir 		    if ( !bCancel )
4282cdf0e10cSrcweir 		    {
4283cdf0e10cSrcweir 			    const SvxZoomItem&	rZoomItem = (const SvxZoomItem&)pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM );
4284cdf0e10cSrcweir                 m_eZoomType = rZoomItem.GetType();
4285cdf0e10cSrcweir                 m_nZoomValue = rZoomItem.GetValue();
4286cdf0e10cSrcweir                 if ( m_eZoomType != SVX_ZOOM_PERCENT )
4287cdf0e10cSrcweir                     m_nZoomValue = getDesignView()->getZoomFactor( m_eZoomType );
4288cdf0e10cSrcweir 
4289cdf0e10cSrcweir                 impl_zoom_nothrow();
4290cdf0e10cSrcweir 		    } // if ( !bCancel )
4291cdf0e10cSrcweir         }
4292cdf0e10cSrcweir         catch(uno::Exception&)
4293cdf0e10cSrcweir 	    {
4294cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
4295cdf0e10cSrcweir 	    }
4296cdf0e10cSrcweir         SfxItemPool::Free(pPool);
4297cdf0e10cSrcweir 
4298cdf0e10cSrcweir 	    for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
4299cdf0e10cSrcweir 		    delete pDefaults[i];
4300cdf0e10cSrcweir 	} // if(pFact)
4301cdf0e10cSrcweir }
4302cdf0e10cSrcweir // -----------------------------------------------------------------------------
4303cdf0e10cSrcweir // -----------------------------------------------------------------------------
4304cdf0e10cSrcweir // XVisualObject
setVisualAreaSize(::sal_Int64 _nAspect,const awt::Size & _aSize)4305cdf0e10cSrcweir void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4306cdf0e10cSrcweir {
4307cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
4308cdf0e10cSrcweir     //if( nAspect == embed::Aspects::MSOLE_CONTENT )
4309cdf0e10cSrcweir     {
4310cdf0e10cSrcweir         bool bChanged =
4311cdf0e10cSrcweir             (m_aVisualAreaSize.Width != _aSize.Width ||
4312cdf0e10cSrcweir              m_aVisualAreaSize.Height != _aSize.Height);
4313cdf0e10cSrcweir         m_aVisualAreaSize = _aSize;
4314cdf0e10cSrcweir         if( bChanged )
4315cdf0e10cSrcweir             setModified( sal_True );
4316cdf0e10cSrcweir     }
4317cdf0e10cSrcweir 	m_nAspect = _nAspect;
4318cdf0e10cSrcweir }
4319cdf0e10cSrcweir // -----------------------------------------------------------------------------
getVisualAreaSize(::sal_Int64)4320cdf0e10cSrcweir awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4321cdf0e10cSrcweir {
4322cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getMutex() );
4323cdf0e10cSrcweir 	return m_aVisualAreaSize;
4324cdf0e10cSrcweir }
4325cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPreferredVisualRepresentation(::sal_Int64 _nAspect)4326cdf0e10cSrcweir embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4327cdf0e10cSrcweir {
4328cdf0e10cSrcweir     ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
4329cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getMutex() );
4330cdf0e10cSrcweir 	embed::VisualRepresentation aResult;
4331cdf0e10cSrcweir     if ( !m_bInGeneratePreview )
4332cdf0e10cSrcweir     {
4333cdf0e10cSrcweir         m_bInGeneratePreview = true;
4334cdf0e10cSrcweir         try
4335cdf0e10cSrcweir         {
4336cdf0e10cSrcweir             if ( !m_xReportEngine.is() )
4337cdf0e10cSrcweir                 m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW);
4338cdf0e10cSrcweir             const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows();
4339cdf0e10cSrcweir             m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW);
4340cdf0e10cSrcweir             m_xReportEngine->setReportDefinition(m_xReportDefinition);
4341cdf0e10cSrcweir             m_xReportEngine->setActiveConnection(getConnection());
4342cdf0e10cSrcweir             try
4343cdf0e10cSrcweir             {
4344cdf0e10cSrcweir                 Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY);
4345cdf0e10cSrcweir 		        if ( xTransfer.is() )
4346cdf0e10cSrcweir 		        {
4347cdf0e10cSrcweir                     xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize);
4348cdf0e10cSrcweir 			        aResult = xTransfer->getPreferredVisualRepresentation( _nAspect );
4349cdf0e10cSrcweir 		        } // if ( xTransfer.is() )
4350cdf0e10cSrcweir             }
4351cdf0e10cSrcweir             catch( uno::Exception & ex )
4352cdf0e10cSrcweir             {
4353cdf0e10cSrcweir                 (void)ex;
4354cdf0e10cSrcweir             }
4355cdf0e10cSrcweir             m_xReportEngine->setMaxRows(nOldMaxRows);
4356cdf0e10cSrcweir         }
4357cdf0e10cSrcweir         catch( uno::Exception & ex )
4358cdf0e10cSrcweir         {
4359cdf0e10cSrcweir             (void)ex;
4360cdf0e10cSrcweir         }
4361cdf0e10cSrcweir         m_bInGeneratePreview = false;
4362cdf0e10cSrcweir     }
4363cdf0e10cSrcweir 	return aResult;
4364cdf0e10cSrcweir }
4365cdf0e10cSrcweir // -----------------------------------------------------------------------------
getMapUnit(::sal_Int64)4366cdf0e10cSrcweir ::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException)
4367cdf0e10cSrcweir {
4368cdf0e10cSrcweir 	return embed::EmbedMapUnits::ONE_100TH_MM;
4369cdf0e10cSrcweir }
4370cdf0e10cSrcweir // -----------------------------------------------------------------------------
getColumns() const4371cdf0e10cSrcweir uno::Reference< container::XNameAccess > OReportController::getColumns() const
4372cdf0e10cSrcweir {
4373cdf0e10cSrcweir     if ( !m_xColumns.is() && m_xReportDefinition.is() && m_xReportDefinition->getCommand().getLength() )
4374cdf0e10cSrcweir     {
4375cdf0e10cSrcweir 		m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive);
4376cdf0e10cSrcweir     }
4377cdf0e10cSrcweir     return m_xColumns;
4378cdf0e10cSrcweir }
4379cdf0e10cSrcweir // -----------------------------------------------------------------------------
getColumnLabel_throw(const::rtl::OUString & i_sColumnName) const4380cdf0e10cSrcweir ::rtl::OUString OReportController::getColumnLabel_throw(const ::rtl::OUString& i_sColumnName) const
4381cdf0e10cSrcweir {
4382cdf0e10cSrcweir     ::rtl::OUString sLabel;
4383cdf0e10cSrcweir     uno::Reference< container::XNameAccess > xColumns = getColumns();
4384cdf0e10cSrcweir     if ( xColumns.is() && xColumns->hasByName(i_sColumnName) )
4385cdf0e10cSrcweir     {
4386cdf0e10cSrcweir         uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW);
4387cdf0e10cSrcweir         if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
4388cdf0e10cSrcweir             xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
4389cdf0e10cSrcweir     }
4390cdf0e10cSrcweir     return sLabel;
4391cdf0e10cSrcweir }
4392cdf0e10cSrcweir 
4393cdf0e10cSrcweir // -----------------------------------------------------------------------------
getUndoManager() const4394cdf0e10cSrcweir SfxUndoManager& OReportController::getUndoManager() const
4395cdf0e10cSrcweir {
4396cdf0e10cSrcweir     DBG_TESTSOLARMUTEX();
4397cdf0e10cSrcweir         // this is expected to be called during UI actions, so the SM is assumed to be locked
4398cdf0e10cSrcweir 
4399cdf0e10cSrcweir     ::boost::shared_ptr< OReportModel > pReportModel( getSdrModel() );
4400cdf0e10cSrcweir     ENSURE_OR_THROW( !!pReportModel, "no access to our model" );
4401cdf0e10cSrcweir 
4402cdf0e10cSrcweir     SfxUndoManager* pUndoManager( pReportModel->GetSdrUndoManager() );
4403cdf0e10cSrcweir     ENSURE_OR_THROW( pUndoManager != NULL, "no access to our model's UndoManager" );
4404cdf0e10cSrcweir 
4405cdf0e10cSrcweir     return *pUndoManager;
4406cdf0e10cSrcweir }
4407cdf0e10cSrcweir 
4408cdf0e10cSrcweir // -----------------------------------------------------------------------------
clearUndoManager() const4409cdf0e10cSrcweir void OReportController::clearUndoManager() const
4410cdf0e10cSrcweir {
4411cdf0e10cSrcweir     getUndoManager().Clear();
4412cdf0e10cSrcweir }
4413cdf0e10cSrcweir 
4414cdf0e10cSrcweir // -----------------------------------------------------------------------------
addUndoAction(SfxUndoAction * i_pAction)4415cdf0e10cSrcweir void OReportController::addUndoAction( SfxUndoAction* i_pAction )
4416cdf0e10cSrcweir {
4417cdf0e10cSrcweir 	getUndoManager().AddUndoAction( i_pAction );
4418cdf0e10cSrcweir 
4419cdf0e10cSrcweir 	InvalidateFeature( SID_UNDO );
4420cdf0e10cSrcweir 	InvalidateFeature( SID_REDO );
4421cdf0e10cSrcweir }
4422