Update ooo320-m1
[ooovba.git] / reportdesign / source / ui / report / ReportController.cxx
blobb66a893ffa6de64b50c5538c5ca1523c52279996
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportController.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
32 #define RPTUI_ID_LRSPACE 1
33 #define RPTUI_ID_ULSPACE 2
34 #define RPTUI_ID_PAGE 3
35 #define RPTUI_ID_SIZE 4
36 #define RPTUI_ID_PAGE_MODE 5
37 #define RPTUI_ID_START 6
38 #define RPTUI_ID_END 7
39 #define RPTUI_ID_BRUSH 8
40 #define RPTUI_ID_METRIC 9
42 #define ITEMID_LRSPACE RPTUI_ID_LRSPACE
43 #define ITEMID_ULSPACE RPTUI_ID_ULSPACE
44 #define ITEMID_SIZE RPTUI_ID_SIZE
45 #define ITEMID_PAGE RPTUI_ID_PAGE
46 #define ITEMID_BRUSH RPTUI_ID_BRUSH
49 #include "ReportController.hxx"
50 #include "ReportDefinition.hxx"
51 #include "CondFormat.hxx"
52 #include "UITools.hxx"
53 #include "AddField.hxx"
54 #include <toolkit/helper/vclunohelper.hxx>
55 #include "DateTime.hxx"
57 #include <sfx2/filedlghelper.hxx>
58 #include <tools/string.hxx>
59 #include <tools/diagnose_ex.h>
60 #include "rptui_slotid.hrc"
61 #include "reportformula.hxx"
63 #include <comphelper/documentconstants.hxx>
64 #include <comphelper/mediadescriptor.hxx>
65 #include <comphelper/property.hxx>
66 #include <comphelper/sequenceashashmap.hxx>
67 #include <comphelper/types.hxx>
69 #include <connectivity/dbtools.hxx>
70 #include <com/sun/star/view/PaperFormat.hpp>
71 #include <com/sun/star/style/GraphicLocation.hpp>
72 #include <com/sun/star/style/XStyle.hpp>
73 #include <com/sun/star/style/PageStyleLayout.hpp>
74 #include <com/sun/star/style/ParagraphAdjust.hpp>
75 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
76 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
77 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
78 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
79 #include <com/sun/star/frame/FrameSearchFlag.hpp>
80 #include <com/sun/star/datatransfer/XTransferable.hpp>
81 #include <com/sun/star/container/XChild.hpp>
82 #include <com/sun/star/container/XNameContainer.hpp>
83 #include <com/sun/star/report/XImageControl.hpp>
84 #include <com/sun/star/report/XFixedLine.hpp>
85 #include <com/sun/star/report/Function.hpp>
86 #include <com/sun/star/report/XShape.hpp>
87 #include <com/sun/star/awt/FontDescriptor.hpp>
88 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
89 #include <com/sun/star/sdb/XParametersSupplier.hpp>
90 #include <com/sun/star/sdb/CommandType.hpp>
91 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
92 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
93 #include <com/sun/star/embed/ElementModes.hpp>
94 #include <com/sun/star/embed/EmbedMapUnits.hpp>
95 #include <comphelper/streamsection.hxx>
96 #include <com/sun/star/awt/FontWeight.hpp>
97 #include <com/sun/star/awt/FontUnderline.hpp>
98 #include <com/sun/star/awt/TextAlign.hpp>
99 #include <com/sun/star/awt/FontSlant.hpp>
100 #include <com/sun/star/frame/status/FontHeight.hpp>
101 #include <com/sun/star/report/XFormattedField.hpp>
102 #include <com/sun/star/sdb/SQLContext.hpp>
103 #include <com/sun/star/sdbc/SQLWarning.hpp>
104 #include <com/sun/star/beans/PropertyAttribute.hpp>
106 #include <vcl/svapp.hxx>
107 #include <vcl/msgbox.hxx>
108 #include <vcl/waitobj.hxx>
110 #include <svx/fmview.hxx>
111 #include <svx/paperinf.hxx>
112 #include <svx/svxids.hrc>
113 #include <svx/svdobj.hxx>
114 #include <svx/dataaccessdescriptor.hxx>
115 #include <svx/svxenum.hxx>
116 #include <svx/pageitem.hxx>
117 #include <svx/lrspitem.hxx>
118 #include <svx/ulspitem.hxx>
119 #include <svx/sizeitem.hxx>
120 #include <svx/zoomitem.hxx>
121 #include <svx/zoomslideritem.hxx>
122 #include <svx/brshitem.hxx>
123 #include <svx/flagsdef.hxx> //CHINA001
124 #include <svx/svdpagv.hxx>
125 #include <svx/svxdlg.hxx>
126 #include <svx/zoom_def.hxx>
127 #include <svx/dialogs.hrc>
129 #include "DesignView.hxx"
130 #include "ModuleHelper.hxx"
131 #include "RptObject.hxx"
132 #include "Undo.hxx"
133 #include "uistrings.hrc"
134 #include "RptDef.hxx"
135 #include "ReportSection.hxx"
136 #include "SectionView.hxx"
137 #include "UndoActions.hxx"
138 #include "dlgpage.hxx"
139 #include "RptResId.hrc"
141 #include <svtools/itempool.hxx>
142 #include <svtools/itemset.hxx>
143 #include <svtools/aeitem.hxx> //CHINA001
144 #include <svtools/cliplistener.hxx>
145 #include <svtools/syslocale.hxx>
146 #include <svtools/viewoptions.hxx>
148 #include <vos/mutex.hxx>
149 #include "PropertyForward.hxx"
150 #include "SectionWindow.hxx"
152 #include <toolkit/helper/convert.hxx>
153 #include "GroupsSorting.hxx"
154 #include "PageNumber.hxx"
155 #include <toolkit/helper/vclunohelper.hxx>
156 #include "UndoEnv.hxx"
157 #include "InsertFunctions.hxx"
159 #include <boost/mem_fn.hpp>
160 #include <boost/bind.hpp>
161 #include <boost/utility.hpp>
163 #include <cppuhelper/exc_hlp.hxx>
164 #include <unotools/confignode.hxx>
165 #include <helpids.hrc>
167 #include <ReportControllerObserver.hxx>
169 #define MAX_ROWS_FOR_PREVIEW 50
171 using namespace ::com::sun::star;
172 using namespace uno;
173 using namespace io;
174 using namespace beans;
175 using namespace frame;
176 using namespace util;
177 using namespace lang;
178 using namespace container;
179 using namespace sdbcx;
180 using namespace sdbc;
181 using namespace sdb;
182 using namespace ui;
183 using namespace ui::dialogs;
184 using namespace util;
185 using namespace ::dbtools;
186 using namespace ::rptui;
187 using namespace ::dbaui;
188 using namespace ::comphelper;
189 using namespace ::cppu;
191 // -----------------------------------------------------------------------------
192 namespace
194 // comparing two PropertyValue instances
195 struct PropertyValueCompare : public ::std::binary_function< beans::PropertyValue, ::rtl::OUString , bool >
197 bool operator() (const beans::PropertyValue& x, const ::rtl::OUString& y) const
199 return x.Name.equals(y);// ? true : false;
201 bool operator() (const ::rtl::OUString& x,const beans::PropertyValue& y) const
203 return x.equals(y.Name);// ? true : false;
207 void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId)
209 if ( _xReportControlFormat.is() )
213 awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
214 switch(_nId)
216 case SID_ATTR_CHAR_WEIGHT:
217 aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight;
218 break;
219 case SID_ATTR_CHAR_POSTURE:
220 aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant));
221 break;
222 case SID_ATTR_CHAR_UNDERLINE:
223 aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline;
224 break;
225 default:
226 OSL_ENSURE(0,"Illegal value in default!");
227 break;
230 _xReportControlFormat->setFontDescriptor(aFontDescriptor);
232 catch(beans::UnknownPropertyException&)
235 } // if ( xReportControlFormat.is() )
239 // -----------------------------------------------------------------------------
240 void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,
241 ODesignView* _pView,
242 uno::Reference< awt::XWindow>& _xWindow,
243 ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats)
245 uno::Reference< report::XReportControlFormat> xReportControlFormat;
246 if ( aArgs.getLength() )
248 SequenceAsHashMap aMap(aArgs);
249 xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>());
250 _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>());
251 } // if ( aArgs.getLength() )
252 if ( !xReportControlFormat.is() )
254 _pView->fillControlModelSelection(_rControlsFormats);
255 //xReportControlFormat.set( _pView->getCurrentControlModel(),uno::UNO_QUERY);
256 } // if ( !xReportControlFormat.is() )
257 else
258 _rControlsFormats.push_back(xReportControlFormat);
260 if ( !_xWindow.is() )
261 _xWindow = VCLUnoHelper::GetInterface(_pView);
263 // -----------------------------------------------------------------------------
264 ::rtl::OUString SAL_CALL OReportController::getImplementationName() throw( RuntimeException )
266 return getImplementationName_Static();
269 //------------------------------------------------------------------------------
270 ::rtl::OUString OReportController::getImplementationName_Static() throw( RuntimeException )
272 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.comp.ReportDesign"));
274 //------------------------------------------------------------------------------
275 Sequence< ::rtl::OUString> OReportController::getSupportedServiceNames_Static(void) throw( RuntimeException )
277 Sequence< ::rtl::OUString> aSupported(1);
278 aSupported.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ReportDesign"));
279 return aSupported;
281 //-------------------------------------------------------------------------
282 Sequence< ::rtl::OUString> SAL_CALL OReportController::getSupportedServiceNames() throw(RuntimeException)
284 return getSupportedServiceNames_Static();
286 // -------------------------------------------------------------------------
287 Reference< XInterface > OReportController::create(Reference< XComponentContext > const & xContext)
289 return *(new OReportController(xContext));
292 #define PROPERTY_ID_ZOOMVALUE 1
294 DBG_NAME( rpt_OReportController )
295 // -----------------------------------------------------------------------------
296 OReportController::OReportController(Reference< XComponentContext > const & xContext)
297 : OReportController_BASE(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))
298 ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper)
299 ,m_aSelectionListeners( getMutex() )
300 ,m_pMyOwnView(NULL)
301 ,m_pClipbordNotifier(NULL)
302 ,m_pGroupsFloater(NULL)
303 ,m_xContext(xContext)
304 ,m_nSplitPos(-1)
305 ,m_nPageNum(-1)
306 ,m_nSelectionCount(0)
307 ,m_nZoomValue(100)
308 ,m_eZoomType(SVX_ZOOM_PERCENT)
309 ,m_bShowRuler(sal_True)
310 ,m_bGridVisible(sal_True)
311 ,m_bGridUse(sal_True)
312 ,m_bShowProperties(sal_True)
313 ,m_bGroupFloaterWasVisible(sal_False)
314 ,m_bHelplinesMove(sal_True)
315 ,m_bChartEnabled(false)
316 ,m_bChartEnabledAsked(false)
317 ,m_bInGeneratePreview(false)
319 // new Observer
320 m_pReportControllerObserver = new OXReportControllerObserver(*this);
321 m_pReportControllerObserver->acquire();
323 m_sMode = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal"));
324 DBG_CTOR( rpt_OReportController,NULL);
325 registerProperty(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomValue")),PROPERTY_ID_ZOOMVALUE,beans::PropertyAttribute::BOUND| beans::PropertyAttribute::TRANSIENT,&m_nZoomValue,::getCppuType(reinterpret_cast< sal_Int16*>(NULL)));
328 // -----------------------------------------------------------------------------
329 OReportController::~OReportController()
331 DBG_DTOR( rpt_OReportController,NULL);
333 // -----------------------------------------------------------------------------
334 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)
335 IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener)
336 // -----------------------------------------------------------------------------
337 void OReportController::disposing()
340 if ( getView() && m_pClipbordNotifier )
342 m_pClipbordNotifier->ClearCallbackLink();
343 m_pClipbordNotifier->AddRemoveListener( getView(), sal_False );
344 m_pClipbordNotifier->release();
345 m_pClipbordNotifier = NULL;
346 } // if ( getView() && m_pClipbordNotifier )
347 if ( m_pGroupsFloater )
349 SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) );
350 aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pGroupsFloater->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) );
351 ::std::auto_ptr<FloatingWindow> aTemp(m_pGroupsFloater);
352 m_pGroupsFloater = NULL;
357 ::comphelper::disposeComponent( m_xRowSet );
358 ::comphelper::disposeComponent( m_xRowSetMediator );
359 ::comphelper::disposeComponent( m_xFormatter );
361 catch(uno::Exception&)
363 OSL_ENSURE(0,"Exception caught while disposing row sets.");
365 m_xRowSet.clear();
366 m_xRowSetMediator.clear();
368 if ( m_xReportDefinition.is() )
372 ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_pMyOwnView->getMarkedSection();
373 if ( pSectionWindow )
374 pSectionWindow->getReportSection().deactivateOle();
375 getUndoMgr()->Clear(); // clear all undo redo things
376 listen(false);
377 m_pReportControllerObserver->Clear();
378 m_pReportControllerObserver->release();
380 catch(uno::Exception&)
386 EventObject aDisposingEvent( *this );
387 m_aSelectionListeners.disposeAndClear( aDisposingEvent );
390 OReportController_BASE::disposing();
393 // disconnect();
396 m_xReportDefinition.clear();
397 m_aReportModel.reset();
398 m_xFrameLoader.clear();
399 m_xReportEngine.clear();
401 catch(uno::Exception&)
404 if ( m_pMyOwnView )
405 EndListening(*(m_pMyOwnView));
406 m_pView = NULL;
407 m_pMyOwnView = NULL;
409 // -----------------------------------------------------------------------------
410 FeatureState OReportController::GetState(sal_uInt16 _nId) const
412 FeatureState aReturn;
413 // (disabled automatically)
414 aReturn.bEnabled = sal_False;
415 // check this first
416 if ( !getView() )
417 return aReturn;
419 switch (_nId)
421 case SID_RPT_TEXTDOCUMENT:
422 aReturn.bEnabled = isEditable();
423 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT);
424 break;
425 case SID_RPT_SPREADSHEET:
426 aReturn.bEnabled = isEditable();
427 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET);
428 break;
429 case SID_REPORTHEADER_WITHOUT_UNDO:
430 case SID_REPORTFOOTER_WITHOUT_UNDO:
431 case SID_REPORTHEADERFOOTER:
433 aReturn.bEnabled = isEditable();
434 ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT));
435 aReturn.sTitle = sText;
437 break;
438 case SID_PAGEHEADER_WITHOUT_UNDO:
439 case SID_PAGEFOOTER_WITHOUT_UNDO:
440 case SID_PAGEHEADERFOOTER:
442 aReturn.bEnabled = isEditable();
443 ::rtl::OUString sText = String(ModuleRes((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT));
444 aReturn.sTitle = sText;
446 break;
447 case SID_GROUP_APPEND:
448 case SID_GROUP_REMOVE:
449 case SID_GROUPHEADER_WITHOUT_UNDO:
450 case SID_GROUPHEADER:
451 case SID_GROUPFOOTER_WITHOUT_UNDO:
452 case SID_GROUPFOOTER:
453 aReturn.bEnabled = isEditable();
454 break;
455 case SID_ADD_CONTROL_PAIR:
456 aReturn.bEnabled = isEditable();
457 break;
458 case SID_REDO:
459 case SID_UNDO:
460 aReturn = OReportController_BASE::GetState(_nId);
461 aReturn.bEnabled = aReturn.bEnabled;
462 break;
463 case SID_OBJECT_RESIZING:
464 case SID_OBJECT_SMALLESTWIDTH:
465 case SID_OBJECT_SMALLESTHEIGHT:
466 case SID_OBJECT_GREATESTWIDTH:
467 case SID_OBJECT_GREATESTHEIGHT:
468 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection();// && m_pMyOwnView->isAlignPossible();
469 if ( aReturn.bEnabled )
470 aReturn.bEnabled = m_nSelectionCount > 1;
471 break;
473 case SID_DISTRIBUTION:
474 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection();
475 if ( aReturn.bEnabled )
477 OSectionView* pSectionView = getCurrentSectionView();
478 aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2;
480 break;
481 case SID_ARRANGEMENU:
482 case SID_FRAME_DOWN:
483 case SID_FRAME_UP:
484 case SID_FRAME_TO_TOP:
485 case SID_FRAME_TO_BOTTOM:
486 case SID_OBJECT_HEAVEN:
487 case SID_OBJECT_HELL:
488 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection();
489 if ( aReturn.bEnabled )
491 OSectionView* pSectionView = getCurrentSectionView();
492 aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked();
493 if ( aReturn.bEnabled )
495 if ( SID_OBJECT_HEAVEN == _nId )
496 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT;
497 else if ( SID_OBJECT_HELL == _nId )
498 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK;
501 break;
503 case SID_SECTION_SHRINK:
504 case SID_SECTION_SHRINK_TOP:
505 case SID_SECTION_SHRINK_BOTTOM:
507 sal_Int32 nCount = 0;
508 uno::Reference<report::XSection> xSection = m_pMyOwnView->getCurrentSection();
509 if ( xSection.is() )
511 nCount = xSection->getCount();
513 aReturn.bEnabled = isEditable() && nCount > 0;
515 break;
516 case SID_OBJECT_ALIGN:
517 case SID_OBJECT_ALIGN_LEFT:
518 case SID_OBJECT_ALIGN_CENTER:
519 case SID_OBJECT_ALIGN_RIGHT:
520 case SID_OBJECT_ALIGN_UP:
521 case SID_OBJECT_ALIGN_MIDDLE:
522 case SID_OBJECT_ALIGN_DOWN:
523 case SID_SECTION_ALIGN:
524 case SID_SECTION_ALIGN_LEFT:
525 case SID_SECTION_ALIGN_CENTER:
526 case SID_SECTION_ALIGN_RIGHT:
527 case SID_SECTION_ALIGN_UP:
528 case SID_SECTION_ALIGN_MIDDLE:
529 case SID_SECTION_ALIGN_DOWN:
530 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection();// && m_pMyOwnView->isAlignPossible();
531 break;
532 case SID_CUT:
533 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection() && !m_pMyOwnView->isHandleEvent(_nId);
534 break;
535 case SID_COPY:
536 aReturn.bEnabled = m_pMyOwnView->HasSelection() && !m_pMyOwnView->isHandleEvent(_nId);
537 break;
538 case SID_PASTE:
539 aReturn.bEnabled = isEditable() && !m_pMyOwnView->isHandleEvent(_nId) && m_pMyOwnView->IsPasteAllowed();
540 break;
541 case SID_SELECTALL:
542 aReturn.bEnabled = !m_pMyOwnView->isHandleEvent(_nId);
543 break;
544 case SID_SELECTALL_IN_SECTION:
545 aReturn.bEnabled = !m_pMyOwnView->isHandleEvent(_nId);
546 if ( aReturn.bEnabled )
547 aReturn.bEnabled = getCurrentSectionView() != NULL;
548 break;
549 case SID_ESCAPE:
550 aReturn.bEnabled = m_pMyOwnView->GetMode() == RPTUI_INSERT;
551 break;
552 case SID_TERMINATE_INPLACEACTIVATION:
553 aReturn.bEnabled = sal_True;
554 break;
555 case SID_SELECT_ALL_EDITS:
556 case SID_SELECT_ALL_LABELS:
557 aReturn.bEnabled = sal_True;
558 break;
559 case SID_RPT_NEW_FUNCTION:
560 aReturn.bEnabled = isEditable();
561 break;
562 case SID_COLLAPSE_SECTION:
563 case SID_EXPAND_SECTION:
564 case SID_NEXT_MARK:
565 case SID_PREV_MARK:
566 aReturn.bEnabled = isEditable();
567 break;
568 case SID_SELECT:
569 case SID_SELECT_REPORT:
570 aReturn.bEnabled = sal_True;
571 break;
572 case SID_EXECUTE_REPORT:
573 aReturn.bEnabled = isConnected() && m_xReportDefinition.is();
574 break;
575 case SID_DELETE:
576 aReturn.bEnabled = isEditable() && m_pMyOwnView->HasSelection() && !m_pMyOwnView->isHandleEvent(_nId);
577 if ( aReturn.bEnabled )
579 ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_pMyOwnView->getMarkedSection();
580 if ( pSectionWindow )
581 aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive();
584 ::rtl::OUString sText = String(ModuleRes(RID_STR_DELETE));
585 aReturn.sTitle = sText;
587 break;
588 case SID_GRID_VISIBLE:
589 aReturn.bEnabled = isEditable();
590 aReturn.bChecked = m_bGridVisible;
591 break;
592 case SID_GRID_USE:
593 aReturn.bEnabled = isEditable();
594 aReturn.bChecked = m_bGridUse;
595 break;
596 case SID_HELPLINES_MOVE:
597 aReturn.bEnabled = isEditable();
598 aReturn.bChecked = m_bHelplinesMove;
599 break;
600 case SID_RULER:
601 aReturn.bEnabled = isEditable();
602 aReturn.bChecked = m_bShowRuler;
603 break;
604 case SID_OBJECT_SELECT:
605 aReturn.bEnabled = sal_True;
606 aReturn.bChecked = m_pMyOwnView->GetMode() == RPTUI_SELECT;
607 break;
608 case SID_INSERT_DIAGRAM:
609 aReturn.bEnabled = isEditable();
610 aReturn.bInvisible = optional< bool >(!m_bChartEnabled);
611 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_OLE2;
612 break;
613 case SID_FM_FIXEDTEXT:
614 aReturn.bEnabled = isEditable();
615 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_FIXEDTEXT;
616 break;
617 case SID_INSERT_HFIXEDLINE:
618 aReturn.bEnabled = isEditable();
619 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_HFIXEDLINE;
620 break;
621 case SID_INSERT_VFIXEDLINE:
622 aReturn.bEnabled = isEditable();
623 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_VFIXEDLINE;
624 break;
625 case SID_FM_EDIT:
626 aReturn.bEnabled = isEditable();
627 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_FORMATTEDFIELD;
628 break;
629 case SID_FM_IMAGECONTROL:
630 aReturn.bEnabled = isEditable();
631 aReturn.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_DLG_IMAGECONTROL;
632 break;
633 case SID_DRAWTBX_CS_BASIC:
634 case SID_DRAWTBX_CS_BASIC1:
635 case SID_DRAWTBX_CS_BASIC2:
636 case SID_DRAWTBX_CS_BASIC3:
637 case SID_DRAWTBX_CS_BASIC4:
638 case SID_DRAWTBX_CS_BASIC5:
639 case SID_DRAWTBX_CS_BASIC6:
640 case SID_DRAWTBX_CS_BASIC7:
641 case SID_DRAWTBX_CS_BASIC8:
642 case SID_DRAWTBX_CS_BASIC9:
643 case SID_DRAWTBX_CS_BASIC10:
644 case SID_DRAWTBX_CS_BASIC11:
645 case SID_DRAWTBX_CS_BASIC12:
646 case SID_DRAWTBX_CS_BASIC13:
647 case SID_DRAWTBX_CS_BASIC14:
648 case SID_DRAWTBX_CS_BASIC15:
649 case SID_DRAWTBX_CS_BASIC16:
650 case SID_DRAWTBX_CS_BASIC17:
651 case SID_DRAWTBX_CS_BASIC18:
652 case SID_DRAWTBX_CS_BASIC19:
653 case SID_DRAWTBX_CS_BASIC20:
654 case SID_DRAWTBX_CS_BASIC21:
655 case SID_DRAWTBX_CS_BASIC22:
656 impl_fillCustomShapeState_nothrow("diamond",aReturn);
657 break;
658 case SID_DRAWTBX_CS_SYMBOL:
659 case SID_DRAWTBX_CS_SYMBOL1:
660 case SID_DRAWTBX_CS_SYMBOL2:
661 case SID_DRAWTBX_CS_SYMBOL3:
662 case SID_DRAWTBX_CS_SYMBOL4:
663 case SID_DRAWTBX_CS_SYMBOL5:
664 case SID_DRAWTBX_CS_SYMBOL6:
665 case SID_DRAWTBX_CS_SYMBOL7:
666 case SID_DRAWTBX_CS_SYMBOL8:
667 case SID_DRAWTBX_CS_SYMBOL9:
668 case SID_DRAWTBX_CS_SYMBOL10:
669 case SID_DRAWTBX_CS_SYMBOL11:
670 case SID_DRAWTBX_CS_SYMBOL12:
671 case SID_DRAWTBX_CS_SYMBOL13:
672 case SID_DRAWTBX_CS_SYMBOL14:
673 case SID_DRAWTBX_CS_SYMBOL15:
674 case SID_DRAWTBX_CS_SYMBOL16:
675 case SID_DRAWTBX_CS_SYMBOL17:
676 case SID_DRAWTBX_CS_SYMBOL18:
677 impl_fillCustomShapeState_nothrow("smiley",aReturn);
678 break;
679 case SID_DRAWTBX_CS_ARROW:
680 case SID_DRAWTBX_CS_ARROW1:
681 case SID_DRAWTBX_CS_ARROW2:
682 case SID_DRAWTBX_CS_ARROW3:
683 case SID_DRAWTBX_CS_ARROW4:
684 case SID_DRAWTBX_CS_ARROW5:
685 case SID_DRAWTBX_CS_ARROW6:
686 case SID_DRAWTBX_CS_ARROW7:
687 case SID_DRAWTBX_CS_ARROW8:
688 case SID_DRAWTBX_CS_ARROW9:
689 case SID_DRAWTBX_CS_ARROW10:
690 case SID_DRAWTBX_CS_ARROW11:
691 case SID_DRAWTBX_CS_ARROW12:
692 case SID_DRAWTBX_CS_ARROW13:
693 case SID_DRAWTBX_CS_ARROW14:
694 case SID_DRAWTBX_CS_ARROW15:
695 case SID_DRAWTBX_CS_ARROW16:
696 case SID_DRAWTBX_CS_ARROW17:
697 case SID_DRAWTBX_CS_ARROW18:
698 case SID_DRAWTBX_CS_ARROW19:
699 case SID_DRAWTBX_CS_ARROW20:
700 case SID_DRAWTBX_CS_ARROW21:
701 case SID_DRAWTBX_CS_ARROW22:
702 case SID_DRAWTBX_CS_ARROW23:
703 case SID_DRAWTBX_CS_ARROW24:
704 case SID_DRAWTBX_CS_ARROW25:
705 case SID_DRAWTBX_CS_ARROW26:
706 impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn);
707 break;
708 case SID_DRAWTBX_CS_STAR:
709 case SID_DRAWTBX_CS_STAR1:
710 case SID_DRAWTBX_CS_STAR2:
711 case SID_DRAWTBX_CS_STAR3:
712 case SID_DRAWTBX_CS_STAR4:
713 case SID_DRAWTBX_CS_STAR5:
714 case SID_DRAWTBX_CS_STAR6:
715 case SID_DRAWTBX_CS_STAR7:
716 case SID_DRAWTBX_CS_STAR8:
717 case SID_DRAWTBX_CS_STAR9:
718 case SID_DRAWTBX_CS_STAR10:
719 case SID_DRAWTBX_CS_STAR11:
720 case SID_DRAWTBX_CS_STAR12:
721 impl_fillCustomShapeState_nothrow("star5",aReturn);
722 break;
723 case SID_DRAWTBX_CS_FLOWCHART:
724 case SID_DRAWTBX_CS_FLOWCHART1:
725 case SID_DRAWTBX_CS_FLOWCHART2:
726 case SID_DRAWTBX_CS_FLOWCHART3:
727 case SID_DRAWTBX_CS_FLOWCHART4:
728 case SID_DRAWTBX_CS_FLOWCHART5:
729 case SID_DRAWTBX_CS_FLOWCHART6:
730 case SID_DRAWTBX_CS_FLOWCHART7:
731 case SID_DRAWTBX_CS_FLOWCHART8:
732 case SID_DRAWTBX_CS_FLOWCHART9:
733 case SID_DRAWTBX_CS_FLOWCHART10:
734 case SID_DRAWTBX_CS_FLOWCHART11:
735 case SID_DRAWTBX_CS_FLOWCHART12:
736 case SID_DRAWTBX_CS_FLOWCHART13:
737 case SID_DRAWTBX_CS_FLOWCHART14:
738 case SID_DRAWTBX_CS_FLOWCHART15:
739 case SID_DRAWTBX_CS_FLOWCHART16:
740 case SID_DRAWTBX_CS_FLOWCHART17:
741 case SID_DRAWTBX_CS_FLOWCHART18:
742 case SID_DRAWTBX_CS_FLOWCHART19:
743 case SID_DRAWTBX_CS_FLOWCHART20:
744 case SID_DRAWTBX_CS_FLOWCHART21:
745 case SID_DRAWTBX_CS_FLOWCHART22:
746 case SID_DRAWTBX_CS_FLOWCHART23:
747 case SID_DRAWTBX_CS_FLOWCHART24:
748 case SID_DRAWTBX_CS_FLOWCHART25:
749 case SID_DRAWTBX_CS_FLOWCHART26:
750 case SID_DRAWTBX_CS_FLOWCHART27:
751 case SID_DRAWTBX_CS_FLOWCHART28:
752 impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn);
753 break;
754 case SID_DRAWTBX_CS_CALLOUT:
755 case SID_DRAWTBX_CS_CALLOUT1:
756 case SID_DRAWTBX_CS_CALLOUT2:
757 case SID_DRAWTBX_CS_CALLOUT3:
758 case SID_DRAWTBX_CS_CALLOUT4:
759 case SID_DRAWTBX_CS_CALLOUT5:
760 case SID_DRAWTBX_CS_CALLOUT6:
761 case SID_DRAWTBX_CS_CALLOUT7:
762 impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn);
763 break;
764 case SID_RPT_SHOWREPORTEXPLORER:
765 aReturn.bEnabled = m_xReportDefinition.is();
766 aReturn.bChecked = m_pMyOwnView && m_pMyOwnView->isReportExplorerVisible();
767 break;
768 case SID_FM_ADD_FIELD:
769 aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is()
770 && m_xReportDefinition->getCommand().getLength();
771 aReturn.bChecked = m_pMyOwnView && m_pMyOwnView->isAddFieldVisible();
772 break;
773 case SID_SHOW_PROPERTYBROWSER:
774 aReturn.bEnabled = sal_True;
775 aReturn.bChecked = m_bShowProperties;
776 break;
777 case SID_PROPERTYBROWSER_LAST_PAGE:
778 aReturn.bEnabled = sal_True;
779 aReturn.aValue <<= m_sLastActivePage;
780 break;
781 case SID_SPLIT_POSITION:
782 aReturn.bEnabled = sal_True;
783 aReturn.aValue <<= getSplitPos();
784 break;
785 case SID_SAVEDOC:
786 aReturn.bEnabled = isModified() && isEditable();
787 break;
788 case SID_SAVEASDOC:
789 aReturn.bEnabled = isConnected() && isEditable();
790 break;
791 case SID_EDITDOC:
792 aReturn.bChecked = isEditable();
793 break;
794 case SID_PAGEDIALOG:
795 aReturn.bEnabled = isEditable();
796 break;
797 case SID_BACKGROUND_COLOR:
798 impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn);
799 break;
800 case SID_ATTR_CHAR_COLOR_BACKGROUND:
801 aReturn.bEnabled = isEditable();
803 uno::Reference<report::XSection> xSection = m_pMyOwnView->getCurrentSection();
804 if ( xSection.is() )
807 aReturn.aValue <<= xSection->getBackColor();
808 const uno::Reference< report::XReportControlModel> xControlModel(m_pMyOwnView->getCurrentControlModel(),uno::UNO_QUERY);
809 aReturn.bEnabled = !xControlModel.is();
811 catch(beans::UnknownPropertyException&)
814 else
815 aReturn.bEnabled = sal_False;
817 break;
818 case SID_SORTINGANDGROUPING:
819 aReturn.bEnabled = sal_True;
820 aReturn.bChecked = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
821 break;
822 case SID_ATTR_CHAR_WEIGHT:
823 case SID_ATTR_CHAR_POSTURE:
824 case SID_ATTR_CHAR_UNDERLINE:
825 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
826 if ( aReturn.bEnabled )
828 awt::FontDescriptor aFontDescriptor;
829 aReturn.aValue >>= aFontDescriptor;
830 aReturn.aValue.clear();
832 switch(_nId)
834 case SID_ATTR_CHAR_WEIGHT:
835 aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight;
836 break;
837 case SID_ATTR_CHAR_POSTURE:
838 aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
839 break;
840 case SID_ATTR_CHAR_UNDERLINE:
841 aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
842 break;
843 default:
845 } // switch(_nCommand)
847 break;
848 case SID_ATTR_CHAR_COLOR:
849 case SID_ATTR_CHAR_COLOR2:
850 impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn);
851 break;
852 case SID_ATTR_CHAR_FONT:
853 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
854 break;
855 case SID_ATTR_CHAR_FONTHEIGHT:
856 impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn);
857 if ( aReturn.aValue.hasValue() )
859 frame::status::FontHeight aFontHeight;
860 aReturn.aValue >>= aFontHeight.Height;
861 aReturn.aValue <<= aFontHeight; // another type is needed here, so
863 break;
864 case SID_ATTR_PARA_ADJUST_LEFT:
865 case SID_ATTR_PARA_ADJUST_CENTER:
866 case SID_ATTR_PARA_ADJUST_RIGHT:
867 case SID_ATTR_PARA_ADJUST_BLOCK:
868 impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn);
869 if ( aReturn.bEnabled )
871 ::sal_Int16 nParaAdjust = 0;
872 if ( aReturn.aValue >>= nParaAdjust )
874 switch(nParaAdjust)
876 case style::ParagraphAdjust_LEFT:
877 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT;
878 break;
879 case style::ParagraphAdjust_RIGHT:
880 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT;
881 break;
882 case style::ParagraphAdjust_BLOCK:
883 case style::ParagraphAdjust_STRETCH:
884 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK;
885 break;
886 case style::ParagraphAdjust_CENTER:
887 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER;
888 break;
890 } // if ( aReturn.aValue >>= nParaAdjust )
891 aReturn.aValue.clear();
893 break;
895 case SID_INSERT_GRAPHIC:
896 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && m_pMyOwnView->getCurrentSection().is();
897 break;
898 case SID_CHAR_DLG:
899 case SID_SETCONTROLDEFAULTS:
900 aReturn.bEnabled = m_xReportDefinition.is() && isEditable();// && m_pMyOwnView->getCurrentControlModel().is();
901 if ( aReturn.bEnabled )
903 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
904 m_pMyOwnView->fillControlModelSelection(aSelection);
905 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
906 for(; aIter != aSelection.end()
907 && !uno::Reference< report::XFixedLine >(*aIter,uno::UNO_QUERY).is()
908 && !uno::Reference< report::XImageControl >(*aIter,uno::UNO_QUERY).is()
909 && uno::Reference< report::XReportControlFormat >(*aIter,uno::UNO_QUERY).is() ;++aIter)
911 aReturn.bEnabled = !aSelection.empty() && aIter == aSelection.end();
913 break;
914 case SID_CONDITIONALFORMATTING:
916 const uno::Reference< report::XFormattedField> xFormattedField(m_pMyOwnView->getCurrentControlModel(),uno::UNO_QUERY);
917 aReturn.bEnabled = xFormattedField.is();
919 break;
920 case SID_INSERT_FLD_PGNUMBER:
921 case SID_DATETIME:
922 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && m_pMyOwnView->getCurrentSection().is();
923 break;
924 case SID_EXPORTDOC:
925 case SID_EXPORTDOCASPDF:
926 aReturn.bEnabled = m_xReportDefinition.is();
927 break;
928 case SID_PRINTPREVIEW:
929 aReturn.bEnabled = sal_False;
930 break;
931 case SID_ATTR_ZOOM:
932 aReturn.bEnabled = sal_True;
934 SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
935 aZoom.SetValueSet(SVX_ZOOM_ENABLE_50|SVX_ZOOM_ENABLE_75|SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_200);
936 aZoom.QueryValue(aReturn.aValue);
937 //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue);
939 break;
940 case SID_ATTR_ZOOMSLIDER:
941 aReturn.bEnabled = sal_True;
943 SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400);
944 aZoomSlider.AddSnappingPoint(50);
945 aZoomSlider.AddSnappingPoint(75);
946 aZoomSlider.AddSnappingPoint(100);
947 aZoomSlider.AddSnappingPoint(200);
948 aZoomSlider.QueryValue(aReturn.aValue);
949 //aReturn.sTitle = ::rtl::OUString::valueOf((sal_Int32)m_nZoomValue);
951 break;
952 default:
953 aReturn = OReportController_BASE::GetState(_nId);
955 return aReturn;
958 // -----------------------------------------------------------------------------
959 namespace
961 /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call
963 The dispatch might originate from either the toolbar, or the conditional
964 formatting dialog. In both cases, argument formats are different.
966 util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs )
968 util::Color aColor( COL_TRANSPARENT );
969 if ( _rDispatchArgs.getLength() == 1 )
971 OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor );
973 else
975 SequenceAsHashMap aMap( _rDispatchArgs );
976 aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor );
978 return aColor;
982 // -----------------------------------------------------------------------------
983 void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
985 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
986 ::osl::MutexGuard aGuard( getMutex() );
987 if ( !getView() )
989 switch(_nId)
991 case SID_RULER:
992 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
993 aArgs[0].Value >>= m_bShowRuler;
994 break;
995 case SID_HELPLINES_MOVE:
996 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
997 aArgs[0].Value >>= m_bHelplinesMove;
998 break;
999 case SID_GRID_VISIBLE:
1000 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
1001 aArgs[0].Value >>= m_bGridVisible;
1002 break;
1003 case SID_SHOW_PROPERTYBROWSER:
1004 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
1005 aArgs[0].Value >>= m_bShowProperties;
1006 break;
1007 case SID_PROPERTYBROWSER_LAST_PAGE:
1008 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
1009 aArgs[0].Value >>= m_sLastActivePage;
1010 break;
1011 case SID_SPLIT_POSITION:
1012 OSL_ENSURE(aArgs.getLength() == 1,"Invalid length!");
1013 aArgs[0].Value >>= m_nSplitPos;
1014 break;
1016 return; // return without execution
1018 sal_Bool bForceBroadcast = sal_False;
1019 switch(_nId)
1021 case SID_RPT_TEXTDOCUMENT:
1022 if ( m_xReportDefinition.is() )
1023 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT );
1024 break;
1025 case SID_RPT_SPREADSHEET:
1026 if (m_xReportDefinition.is() )
1027 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET );
1028 break;
1029 case SID_REPORTHEADER_WITHOUT_UNDO:
1030 case SID_REPORTFOOTER_WITHOUT_UNDO:
1031 case SID_REPORTHEADERFOOTER:
1032 switchReportSection(_nId);
1033 break;
1034 case SID_PAGEHEADER_WITHOUT_UNDO:
1035 case SID_PAGEFOOTER_WITHOUT_UNDO:
1036 case SID_PAGEHEADERFOOTER:
1037 switchPageSection(_nId);
1038 break;
1039 case SID_GROUP_APPEND:
1040 case SID_GROUP_REMOVE:
1041 modifyGroup(_nId == SID_GROUP_APPEND,aArgs);
1042 break;
1043 case SID_GROUPHEADER_WITHOUT_UNDO:
1044 case SID_GROUPHEADER:
1045 createGroupSection(SID_GROUPHEADER == _nId,true,aArgs);
1046 break;
1047 case SID_GROUPFOOTER_WITHOUT_UNDO:
1048 case SID_GROUPFOOTER:
1049 createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs);
1050 break;
1051 case SID_ADD_CONTROL_PAIR:
1052 addPairControls(aArgs);
1053 break;
1054 case SID_REDO:
1055 case SID_UNDO:
1057 // const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
1058 // We would like to know if we are in undo mode
1059 const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() );
1060 OReportController_BASE::Execute( _nId, aArgs );
1061 InvalidateAll();
1062 updateFloater();
1064 break;
1065 case SID_CUT:
1066 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Cut));
1067 break;
1068 case SID_COPY:
1069 m_pMyOwnView->Copy();
1070 break;
1071 case SID_PASTE:
1072 executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fun(&ODesignView::Paste));
1073 break;
1075 case SID_FRAME_TO_TOP:
1076 case SID_FRAME_DOWN:
1077 case SID_FRAME_UP:
1078 case SID_FRAME_TO_BOTTOM:
1079 case SID_OBJECT_HEAVEN:
1080 case SID_OBJECT_HELL:
1081 changeZOrder(_nId);
1082 break;
1083 case SID_DISTRIBUTION:
1085 OSectionView* pSectionView = getCurrentSectionView();
1086 if ( pSectionView )
1087 pSectionView->DistributeMarkedObjects();
1089 break;
1090 case SID_OBJECT_SMALLESTWIDTH:
1091 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST);
1092 break;
1093 case SID_OBJECT_SMALLESTHEIGHT:
1094 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST);
1095 break;
1096 case SID_OBJECT_GREATESTWIDTH:
1097 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST);
1098 break;
1099 case SID_OBJECT_GREATESTHEIGHT:
1100 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST);
1101 break;
1102 case SID_SECTION_ALIGN_LEFT:
1103 case SID_OBJECT_ALIGN_LEFT:
1104 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId);
1105 break;
1106 case SID_SECTION_ALIGN_CENTER:
1107 case SID_OBJECT_ALIGN_CENTER:
1108 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId);
1109 break;
1110 case SID_SECTION_ALIGN_RIGHT:
1111 case SID_OBJECT_ALIGN_RIGHT:
1112 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId);
1113 break;
1114 case SID_SECTION_ALIGN_UP:
1115 case SID_OBJECT_ALIGN_UP:
1116 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId);
1117 break;
1118 case SID_SECTION_ALIGN_MIDDLE:
1119 case SID_OBJECT_ALIGN_MIDDLE:
1120 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId);
1121 break;
1122 case SID_SECTION_ALIGN_DOWN:
1123 case SID_OBJECT_ALIGN_DOWN:
1124 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId);
1125 break;
1127 case SID_SECTION_SHRINK_BOTTOM:
1128 case SID_SECTION_SHRINK_TOP:
1129 case SID_SECTION_SHRINK:
1131 uno::Reference<report::XSection> xSection = m_pMyOwnView->getCurrentSection();
1132 shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId);
1134 break;
1136 case SID_SELECTALL:
1137 m_pMyOwnView->SelectAll(OBJ_NONE);
1138 break;
1139 case SID_SELECTALL_IN_SECTION:
1141 OSectionView* pSectionView = getCurrentSectionView();
1142 if ( pSectionView )
1143 pSectionView->MarkAll();
1145 break;
1146 case SID_ESCAPE:
1147 m_pMyOwnView->SetMode(RPTUI_SELECT);
1148 InvalidateFeature( SID_OBJECT_SELECT );
1149 break;
1150 case SID_SELECT_ALL_EDITS:
1151 m_pMyOwnView->SelectAll(OBJ_DLG_FORMATTEDFIELD);
1152 break;
1153 case SID_SELECT_ALL_LABELS:
1154 m_pMyOwnView->SelectAll(OBJ_DLG_FIXEDTEXT);
1155 break;
1156 case SID_TERMINATE_INPLACEACTIVATION:
1158 ::boost::shared_ptr<OSectionWindow> pSection = m_pMyOwnView->getMarkedSection();
1159 if ( pSection )
1160 pSection->getReportSection().deactivateOle();
1162 break;
1163 case SID_SELECT:
1164 if ( aArgs.getLength() == 1 )
1165 select(aArgs[0].Value);
1166 break;
1167 case SID_SELECT_REPORT:
1168 select(uno::makeAny(m_xReportDefinition));
1169 break;
1170 case SID_EXECUTE_REPORT:
1171 /*m_nExecuteReportEvent = */getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport));
1172 break;
1173 case SID_RPT_NEW_FUNCTION:
1174 createNewFunction(aArgs[0].Value);
1175 break;
1176 case SID_COLLAPSE_SECTION:
1177 collapseSection(true);
1178 break;
1179 case SID_EXPAND_SECTION:
1180 collapseSection(false);
1181 break;
1182 case SID_NEXT_MARK:
1183 markSection(true);
1184 break;
1185 case SID_PREV_MARK:
1186 markSection(false);
1187 break;
1188 case SID_DELETE:
1189 if ( aArgs.getLength() == 1 )
1191 uno::Reference< report::XFunction> xFunction;
1192 aArgs[0].Value >>= xFunction;
1193 if ( xFunction.is() )
1195 uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW);
1196 sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction);
1197 const String sUndoAction = String((ModuleRes(RID_STR_UNDO_REMOVE_FUNCTION)));
1198 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
1199 xFunctions->removeByIndex(nIndex);
1200 select(uno::makeAny(xFunctions->getParent()));
1201 InvalidateFeature( SID_SAVEDOC );
1202 InvalidateFeature( SID_UNDO );
1205 else
1206 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fun(&ODesignView::Delete));
1207 break;
1208 case SID_GRID_USE:
1209 m_pMyOwnView->setGridSnap(m_bGridUse = !m_bGridUse);
1210 break;
1211 case SID_HELPLINES_MOVE:
1212 m_pMyOwnView->setDragStripes(m_bHelplinesMove = !m_bHelplinesMove);
1213 break;
1214 case SID_GRID_VISIBLE:
1215 m_pMyOwnView->toggleGrid(m_bGridVisible = !m_bGridVisible);
1216 break;
1217 case SID_RULER:
1218 m_pMyOwnView->showRuler(m_bShowRuler = !m_bShowRuler);
1219 break;
1220 case SID_OBJECT_SELECT:
1221 m_pMyOwnView->SetMode(RPTUI_SELECT);
1222 InvalidateAll();
1223 break;
1224 case SID_INSERT_DIAGRAM:
1226 OSectionView* pView = getCurrentSectionView();
1227 if ( pView )
1229 Reference< awt::XWindow> xWindow = VCLUnoHelper::GetInterface(getView()->Window::GetParent());
1230 InsertChart(m_xContext,m_xReportDefinition.get(),xWindow,pView,getSdrModel().get());
1233 m_pMyOwnView->SetMode( RPTUI_INSERT );
1234 m_pMyOwnView->SetInsertObj( OBJ_OLE2);
1235 createDefaultControl(aArgs);
1236 InvalidateAll();
1237 break;
1238 case SID_FM_FIXEDTEXT:
1239 m_pMyOwnView->SetMode( RPTUI_INSERT );
1240 m_pMyOwnView->SetInsertObj( OBJ_DLG_FIXEDTEXT );
1241 createDefaultControl(aArgs);
1242 InvalidateAll();
1243 break;
1244 case SID_INSERT_HFIXEDLINE:
1245 m_pMyOwnView->SetMode( RPTUI_INSERT );
1246 m_pMyOwnView->SetInsertObj( OBJ_DLG_HFIXEDLINE );
1247 createDefaultControl(aArgs);
1248 InvalidateAll();
1249 break;
1250 case SID_INSERT_VFIXEDLINE:
1251 m_pMyOwnView->SetMode( RPTUI_INSERT );
1252 m_pMyOwnView->SetInsertObj( OBJ_DLG_VFIXEDLINE );
1253 createDefaultControl(aArgs);
1254 InvalidateAll();
1255 break;
1256 case SID_FM_EDIT:
1257 m_pMyOwnView->SetMode( RPTUI_INSERT );
1258 m_pMyOwnView->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
1259 createDefaultControl(aArgs);
1260 InvalidateAll();
1261 break;
1262 case SID_FM_IMAGECONTROL:
1263 m_pMyOwnView->SetMode( RPTUI_INSERT );
1264 m_pMyOwnView->SetInsertObj( OBJ_DLG_IMAGECONTROL );
1265 createDefaultControl(aArgs);
1266 InvalidateAll();
1267 break;
1268 case SID_DRAWTBX_CS_BASIC:
1269 case SID_DRAWTBX_CS_BASIC1:
1270 case SID_DRAWTBX_CS_BASIC2:
1271 case SID_DRAWTBX_CS_BASIC3:
1272 case SID_DRAWTBX_CS_BASIC4:
1273 case SID_DRAWTBX_CS_BASIC5:
1274 case SID_DRAWTBX_CS_BASIC6:
1275 case SID_DRAWTBX_CS_BASIC7:
1276 case SID_DRAWTBX_CS_BASIC8:
1277 case SID_DRAWTBX_CS_BASIC9:
1278 case SID_DRAWTBX_CS_BASIC10:
1279 case SID_DRAWTBX_CS_BASIC11:
1280 case SID_DRAWTBX_CS_BASIC12:
1281 case SID_DRAWTBX_CS_BASIC13:
1282 case SID_DRAWTBX_CS_BASIC14:
1283 case SID_DRAWTBX_CS_BASIC15:
1284 case SID_DRAWTBX_CS_BASIC16:
1285 case SID_DRAWTBX_CS_BASIC17:
1286 case SID_DRAWTBX_CS_BASIC18:
1287 case SID_DRAWTBX_CS_BASIC19:
1288 case SID_DRAWTBX_CS_BASIC20:
1289 case SID_DRAWTBX_CS_BASIC21:
1290 case SID_DRAWTBX_CS_BASIC22:
1291 case SID_DRAWTBX_CS_SYMBOL1:
1292 case SID_DRAWTBX_CS_SYMBOL2:
1293 case SID_DRAWTBX_CS_SYMBOL3:
1294 case SID_DRAWTBX_CS_SYMBOL4:
1295 case SID_DRAWTBX_CS_SYMBOL5:
1296 case SID_DRAWTBX_CS_SYMBOL6:
1297 case SID_DRAWTBX_CS_SYMBOL7:
1298 case SID_DRAWTBX_CS_SYMBOL8:
1299 case SID_DRAWTBX_CS_SYMBOL9:
1300 case SID_DRAWTBX_CS_SYMBOL10:
1301 case SID_DRAWTBX_CS_SYMBOL11:
1302 case SID_DRAWTBX_CS_SYMBOL12:
1303 case SID_DRAWTBX_CS_SYMBOL13:
1304 case SID_DRAWTBX_CS_SYMBOL14:
1305 case SID_DRAWTBX_CS_SYMBOL15:
1306 case SID_DRAWTBX_CS_SYMBOL16:
1307 case SID_DRAWTBX_CS_SYMBOL17:
1308 case SID_DRAWTBX_CS_SYMBOL18:
1309 case SID_DRAWTBX_CS_ARROW1:
1310 case SID_DRAWTBX_CS_ARROW2:
1311 case SID_DRAWTBX_CS_ARROW3:
1312 case SID_DRAWTBX_CS_ARROW4:
1313 case SID_DRAWTBX_CS_ARROW5:
1314 case SID_DRAWTBX_CS_ARROW6:
1315 case SID_DRAWTBX_CS_ARROW7:
1316 case SID_DRAWTBX_CS_ARROW8:
1317 case SID_DRAWTBX_CS_ARROW9:
1318 case SID_DRAWTBX_CS_ARROW10:
1319 case SID_DRAWTBX_CS_ARROW11:
1320 case SID_DRAWTBX_CS_ARROW12:
1321 case SID_DRAWTBX_CS_ARROW13:
1322 case SID_DRAWTBX_CS_ARROW14:
1323 case SID_DRAWTBX_CS_ARROW15:
1324 case SID_DRAWTBX_CS_ARROW16:
1325 case SID_DRAWTBX_CS_ARROW17:
1326 case SID_DRAWTBX_CS_ARROW18:
1327 case SID_DRAWTBX_CS_ARROW19:
1328 case SID_DRAWTBX_CS_ARROW20:
1329 case SID_DRAWTBX_CS_ARROW21:
1330 case SID_DRAWTBX_CS_ARROW22:
1331 case SID_DRAWTBX_CS_ARROW23:
1332 case SID_DRAWTBX_CS_ARROW24:
1333 case SID_DRAWTBX_CS_ARROW25:
1334 case SID_DRAWTBX_CS_ARROW26:
1335 case SID_DRAWTBX_CS_STAR1:
1336 case SID_DRAWTBX_CS_STAR2:
1337 case SID_DRAWTBX_CS_STAR3:
1338 case SID_DRAWTBX_CS_STAR4:
1339 case SID_DRAWTBX_CS_STAR5:
1340 case SID_DRAWTBX_CS_STAR6:
1341 case SID_DRAWTBX_CS_STAR7:
1342 case SID_DRAWTBX_CS_STAR8:
1343 case SID_DRAWTBX_CS_STAR9:
1344 case SID_DRAWTBX_CS_STAR10:
1345 case SID_DRAWTBX_CS_STAR11:
1346 case SID_DRAWTBX_CS_STAR12:
1347 case SID_DRAWTBX_CS_FLOWCHART1:
1348 case SID_DRAWTBX_CS_FLOWCHART2:
1349 case SID_DRAWTBX_CS_FLOWCHART3:
1350 case SID_DRAWTBX_CS_FLOWCHART4:
1351 case SID_DRAWTBX_CS_FLOWCHART5:
1352 case SID_DRAWTBX_CS_FLOWCHART6:
1353 case SID_DRAWTBX_CS_FLOWCHART7:
1354 case SID_DRAWTBX_CS_FLOWCHART8:
1355 case SID_DRAWTBX_CS_FLOWCHART9:
1356 case SID_DRAWTBX_CS_FLOWCHART10:
1357 case SID_DRAWTBX_CS_FLOWCHART11:
1358 case SID_DRAWTBX_CS_FLOWCHART12:
1359 case SID_DRAWTBX_CS_FLOWCHART13:
1360 case SID_DRAWTBX_CS_FLOWCHART14:
1361 case SID_DRAWTBX_CS_FLOWCHART15:
1362 case SID_DRAWTBX_CS_FLOWCHART16:
1363 case SID_DRAWTBX_CS_FLOWCHART17:
1364 case SID_DRAWTBX_CS_FLOWCHART18:
1365 case SID_DRAWTBX_CS_FLOWCHART19:
1366 case SID_DRAWTBX_CS_FLOWCHART20:
1367 case SID_DRAWTBX_CS_FLOWCHART21:
1368 case SID_DRAWTBX_CS_FLOWCHART22:
1369 case SID_DRAWTBX_CS_FLOWCHART23:
1370 case SID_DRAWTBX_CS_FLOWCHART24:
1371 case SID_DRAWTBX_CS_FLOWCHART25:
1372 case SID_DRAWTBX_CS_FLOWCHART26:
1373 case SID_DRAWTBX_CS_FLOWCHART27:
1374 case SID_DRAWTBX_CS_FLOWCHART28:
1375 case SID_DRAWTBX_CS_CALLOUT1:
1376 case SID_DRAWTBX_CS_CALLOUT2:
1377 case SID_DRAWTBX_CS_CALLOUT3:
1378 case SID_DRAWTBX_CS_CALLOUT4:
1379 case SID_DRAWTBX_CS_CALLOUT5:
1380 case SID_DRAWTBX_CS_CALLOUT6:
1381 case SID_DRAWTBX_CS_CALLOUT7:
1382 case SID_DRAWTBX_CS_SYMBOL:
1383 case SID_DRAWTBX_CS_ARROW:
1384 case SID_DRAWTBX_CS_FLOWCHART:
1385 case SID_DRAWTBX_CS_CALLOUT:
1386 case SID_DRAWTBX_CS_STAR:
1387 m_pMyOwnView->SetMode( RPTUI_INSERT );
1389 URL aUrl = getURLForId(_nId);
1390 sal_Int32 nIndex = 1;
1391 ::rtl::OUString sType = aUrl.Complete.getToken(0,'.',nIndex);
1392 if ( nIndex == -1 || !sType.getLength() )
1394 switch(_nId)
1396 case SID_DRAWTBX_CS_SYMBOL:
1397 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("smiley"));
1398 break;
1399 case SID_DRAWTBX_CS_ARROW:
1400 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("left-right-arrow"));
1401 break;
1402 case SID_DRAWTBX_CS_FLOWCHART:
1403 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("flowchart-internal-storage"));
1404 break;
1405 case SID_DRAWTBX_CS_CALLOUT:
1406 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("round-rectangular-callout"));
1407 break;
1408 case SID_DRAWTBX_CS_STAR:
1409 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("star5"));
1410 break;
1411 case SID_DRAWTBX_CS_BASIC:
1412 default:
1413 sType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond"));
1416 else
1417 sType = aUrl.Complete.getToken(0,'.',nIndex);
1419 m_pMyOwnView->SetInsertObj( OBJ_CUSTOMSHAPE ,sType);
1420 createDefaultControl(aArgs);
1422 InvalidateAll();
1423 break;
1424 case SID_RPT_SHOWREPORTEXPLORER:
1425 if ( isUiVisible() )
1426 m_pMyOwnView->toggleReportExplorer();
1427 break;
1428 case SID_FM_ADD_FIELD:
1429 if ( isUiVisible() )
1430 m_pMyOwnView->toggleAddField();
1431 break;
1432 case SID_SHOW_PROPERTYBROWSER:
1433 if ( m_bShowProperties )
1434 m_sLastActivePage = m_pMyOwnView->getCurrentPage();
1435 else
1436 m_pMyOwnView->setCurrentPage(m_sLastActivePage);
1438 if ( isUiVisible() )
1440 m_bShowProperties = !m_bShowProperties;
1441 if ( aArgs.getLength() == 1 )
1442 aArgs[0].Value >>= m_bShowProperties;
1444 m_pMyOwnView->togglePropertyBrowser(m_bShowProperties);
1446 break;
1447 case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do
1448 m_sLastActivePage = m_pMyOwnView->getCurrentPage();
1449 break;
1450 case SID_SPLIT_POSITION:
1451 m_pMyOwnView->Resize();
1452 break;
1453 case SID_PAGEDIALOG:
1454 case SID_ATTR_CHAR_COLOR_BACKGROUND:
1456 uno::Reference<report::XSection> xSection;
1457 if (aArgs.getLength() == 1 )
1458 aArgs[0].Value >>= xSection;
1459 openPageDialog(xSection);
1460 bForceBroadcast = sal_True;
1462 break;
1463 case SID_SORTINGANDGROUPING:
1464 openSortingAndGroupingDialog();
1465 m_bGroupFloaterWasVisible = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
1466 break;
1467 case SID_BACKGROUND_COLOR:
1469 const util::Color aColor( lcl_extractBackgroundColor( aArgs ) );
1470 if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) )
1472 uno::Reference< report::XSection > xSection = m_pMyOwnView->getCurrentSection();
1473 if ( xSection.is() )
1475 xSection->setBackColor( aColor );
1478 bForceBroadcast = sal_True;
1480 break;
1481 case SID_ATTR_CHAR_WEIGHT:
1482 case SID_ATTR_CHAR_POSTURE:
1483 case SID_ATTR_CHAR_UNDERLINE:
1485 ::std::auto_ptr<UndoManagerListAction> pListAction;
1486 uno::Reference< awt::XWindow> xWindow;
1487 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1488 lcl_getReportControlFormat(aArgs,m_pMyOwnView,xWindow,aControlsFormats);
1489 bool bMulti = aControlsFormats.size() > 1;
1490 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
1491 for(; aIter != aControlsFormats.end();++aIter)
1493 if ( !pListAction.get() && bMulti)
1495 const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT));
1496 pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction));
1497 } // if ( !pListAction.get() )
1498 uno::Reference< report::XReportControlFormat> xReportControlFormat(*aIter,uno::UNO_QUERY);
1499 lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
1502 break;
1503 case SID_ATTR_CHAR_COLOR:
1504 case SID_ATTR_CHAR_COLOR2:
1506 const SequenceAsHashMap aMap(aArgs);
1507 const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color());
1508 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs);
1509 bForceBroadcast = sal_True;
1511 break;
1512 case SID_ATTR_CHAR_FONT:
1513 if ( aArgs.getLength() == 1 )
1515 awt::FontDescriptor aFont;
1516 if ( aArgs[0].Value >>= aFont )
1518 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs);
1519 } // if ( aArgs[0].Value >>= aFont )
1521 break;
1522 case SID_ATTR_CHAR_FONTHEIGHT:
1523 if ( aArgs.getLength() == 1 )
1525 float fSelVal = 0.0;
1526 if ( aArgs[0].Value >>= fSelVal )
1527 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs);
1529 break;
1530 case SID_ATTR_PARA_ADJUST_LEFT:
1531 case SID_ATTR_PARA_ADJUST_CENTER:
1532 case SID_ATTR_PARA_ADJUST_RIGHT:
1533 case SID_ATTR_PARA_ADJUST_BLOCK:
1535 sal_Int16 eParagraphAdjust = style::ParagraphAdjust_LEFT;
1536 switch(_nId)
1538 case SID_ATTR_PARA_ADJUST_LEFT:
1539 eParagraphAdjust = style::ParagraphAdjust_LEFT;
1540 break;
1541 case SID_ATTR_PARA_ADJUST_CENTER:
1542 eParagraphAdjust = style::ParagraphAdjust_CENTER;
1543 break;
1544 case SID_ATTR_PARA_ADJUST_RIGHT:
1545 eParagraphAdjust = style::ParagraphAdjust_RIGHT;
1546 break;
1547 case SID_ATTR_PARA_ADJUST_BLOCK:
1548 eParagraphAdjust = style::ParagraphAdjust_BLOCK;
1549 break;
1550 } // switch(_nId)
1551 impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(eParagraphAdjust),aArgs);
1553 InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT);
1554 InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER);
1555 InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT);
1556 InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK);
1558 break;
1559 case SID_CHAR_DLG:
1561 ::std::auto_ptr<UndoManagerListAction> pListAction;
1562 uno::Sequence< beans::NamedValue > aSettings;
1563 uno::Reference< awt::XWindow> xWindow;
1564 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1565 lcl_getReportControlFormat(aArgs,m_pMyOwnView,xWindow,aControlsFormats);
1566 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aControlsFormats.begin();
1567 for(; aIter != aControlsFormats.end();++aIter)
1569 uno::Reference< report::XReportControlFormat > xFormat(*aIter,uno::UNO_QUERY);
1570 if ( xFormat.is() )
1572 if ( !pListAction.get() )
1574 const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEFONT));
1575 pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction));
1576 rptui::openCharDialog(xFormat,xWindow,aSettings);
1577 } // if ( !pListAction.get() )
1578 applyCharacterSettings( xFormat, aSettings );
1580 } // for(; aIter != aControlsFormats.end();++aIter)
1581 if ( !aControlsFormats.empty() )
1582 InvalidateAll();
1584 break;
1585 //case SID_FM_DESIGN_MODE:
1586 // break;
1587 case SID_INSERT_GRAPHIC:
1588 insertGraphic();
1589 break;
1590 case SID_SETCONTROLDEFAULTS:
1591 break;
1592 case SID_CONDITIONALFORMATTING:
1594 uno::Reference< report::XFormattedField> xFormattedField(m_pMyOwnView->getCurrentControlModel(),uno::UNO_QUERY);
1595 if ( xFormattedField.is() )
1597 ConditionalFormattingDialog aDlg( getView(), xFormattedField.get(), *this );
1598 aDlg.Execute();
1601 break;
1602 case SID_DATETIME:
1603 if ( m_xReportDefinition.is() )
1605 if ( !aArgs.getLength() )
1607 ODateTimeDialog aDlg(getView(),m_pMyOwnView->getCurrentSection(),this);
1608 aDlg.Execute();
1610 else
1611 createDateTime(aArgs);
1612 } // if ( m_xReportDefinition.is() )
1613 break;
1614 case SID_INSERT_FLD_PGNUMBER:
1615 if ( m_xReportDefinition.is() )
1617 if ( !aArgs.getLength() )
1619 OPageNumberDialog aDlg(getView(),m_xReportDefinition,this);
1620 aDlg.Execute();
1622 else
1623 createPageNumber(aArgs);
1624 } // if ( m_xReportDefinition.is() )
1625 break;
1626 case SID_EXPORTDOC:
1627 case SID_EXPORTDOCASPDF:
1628 break;
1629 case SID_PRINTPREVIEW:
1630 if ( m_xReportDefinition.is() )
1633 break;
1634 case SID_EDITDOC:
1635 if(isEditable())
1636 { // the state should be changed to not editable
1637 switch (saveModified())
1639 case RET_CANCEL:
1640 // don't change anything here so return
1641 return;
1642 case RET_NO:
1643 setModified(sal_False); // and we are not modified yet
1644 break;
1645 default:
1646 break;
1649 setEditable(!isEditable());
1650 //getJoinView()->setReadOnly(!isEditable());
1651 InvalidateAll();
1652 return;
1653 case SID_GROUP:
1654 break;
1655 case SID_ATTR_ZOOM:
1656 if ( aArgs.getLength() == 0 )
1658 openZoomDialog();
1660 else if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") )
1662 SvxZoomItem aZoomItem;
1663 aZoomItem.PutValue(aArgs[0].Value);
1664 m_nZoomValue = aZoomItem.GetValue();
1665 m_eZoomType = aZoomItem.GetType();
1666 impl_zoom_nothrow();
1667 } // if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("Zoom") )
1668 break;
1669 case SID_ATTR_ZOOMSLIDER:
1670 if ( aArgs.getLength() == 1 && aArgs[0].Name.equalsAscii("ZoomSlider") )
1672 SvxZoomSliderItem aZoomSlider;
1673 aZoomSlider.PutValue(aArgs[0].Value);
1674 m_nZoomValue = aZoomSlider.GetValue();
1675 m_eZoomType = SVX_ZOOM_PERCENT;
1676 impl_zoom_nothrow();
1678 break;
1679 default:
1680 OReportController_BASE::Execute(_nId,aArgs);
1682 InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast);
1684 // -----------------------------------------------------------------------------
1685 short OReportController::saveModified()
1687 return RET_NO;
1689 // -----------------------------------------------------------------------------
1690 void OReportController::impl_initialize( )
1692 OReportController_BASE::impl_initialize();
1694 const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
1696 rArguments.get_ensureType( (::rtl::OUString)PROPERTY_REPORTNAME, m_sName );
1697 if ( !m_sName.getLength() )
1698 rArguments.get_ensureType( "DocumentTitle", m_sName );
1702 if ( m_xReportDefinition.is() )
1704 //m_sName = m_xReportDefinition->getName();
1705 getView()->initialize(); // show the windows and fill with our informations
1706 getUndoMgr()->Clear(); // clear all undo redo things
1707 getSdrModel();
1708 if ( !m_aReportModel )
1709 throw Exception();
1711 ::comphelper::NamedValueCollection aArgs(getModel()->getArgs());
1712 setMode(aArgs.getOrDefault("Mode", rtl::OUString::createFromAscii("normal")));
1714 listen(true);
1715 setEditable( !m_aReportModel->IsReadOnly() );
1716 m_xFormatter.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
1717 m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY));
1719 ::comphelper::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() );
1720 ::rtl::OUString sHierarchicalDocumentName;
1721 sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HierarchicalDocumentName")),sHierarchicalDocumentName);
1723 if ( !sHierarchicalDocumentName.getLength() && getConnection().is() )
1725 uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW);
1726 uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables();
1727 const uno::Sequence< ::rtl::OUString > aNames( xTables->getElementNames() );
1729 if ( aNames.hasElements() )
1731 m_xReportDefinition->setCommand(aNames[0]);
1732 m_xReportDefinition->setCommandType(sdb::CommandType::TABLE);
1736 } // if ( m_xReportDefinition.is() )
1738 // check if chart is supported by the engine
1739 checkChartEnabled();
1740 // restore the view data
1741 m_pMyOwnView->toggleGrid(m_bGridVisible);
1742 m_pMyOwnView->showRuler(m_bShowRuler);
1743 m_pMyOwnView->togglePropertyBrowser(m_bShowProperties);
1744 m_pMyOwnView->setCurrentPage(m_sLastActivePage);
1745 m_pMyOwnView->unmarkAllObjects(NULL);
1747 if ( m_nPageNum != -1 )
1749 if ( m_nPageNum < m_aReportModel->GetPageCount() )
1751 const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum)));
1752 if ( pPage )
1754 uno::Sequence< beans::PropertyValue> aArgs(1);
1755 aArgs[0].Value <<= pPage->getSection();
1756 executeUnChecked(SID_SELECT,aArgs);
1759 else
1760 m_nPageNum = -1;
1762 m_pMyOwnView->collapseSections(m_aCollapsedSections);
1763 impl_zoom_nothrow();
1764 m_pMyOwnView->Resize();
1765 m_pMyOwnView->Invalidate();
1766 InvalidateAll();
1768 if ( m_bShowProperties && m_nPageNum == -1 )
1770 m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"));
1771 m_pMyOwnView->setCurrentPage(m_sLastActivePage);
1772 uno::Sequence< beans::PropertyValue> aArgs;
1773 executeUnChecked(SID_SELECT_REPORT,aArgs);
1774 } // if ( m_bShowProperties && m_nPageNum == -1 )
1776 setModified(sal_False); // and we are not modified yet
1778 // open the global help agent
1779 // we need a Frame but at this time there is no frame, therefore we send a UserEvent
1780 getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
1782 catch(const SQLException&)
1784 OSL_ENSURE(sal_False, "OReportController::initialize: caught an exception!");
1787 // -----------------------------------------------------------------------------
1788 IMPL_LINK( OReportController, OnOpenHelpAgent, void* ,/*_pMemfun*/)
1790 //m_nExecuteReportEvent = 0;
1791 doOpenHelpAgent();
1792 return 0L;
1794 // -----------------------------------------------------------------------------
1795 IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow* ,_pAddFieldDlg)
1797 WaitObject aObj(m_pMyOwnView);
1798 uno::Sequence< beans::PropertyValue > aArgs = _pAddFieldDlg->getSelectedFieldDescriptors();
1799 // we use this way to create undo actions
1800 if ( aArgs.getLength() )
1802 executeChecked(SID_ADD_CONTROL_PAIR,aArgs);
1804 return 0L;
1806 // -----------------------------------------------------------------------------
1808 void OReportController::doOpenHelpAgent()
1810 if (getFrame().is())
1812 rtl::OUString suURL = rtl::OUString::createFromAscii("vnd.sun.star.help://shared/text/shared/explorer/database/rep_main.xhp?UseDB=no&DbPAR=swriter");
1813 openHelpAgent(suURL);
1814 // openHelpAgent(68245 /* HID_REPORT_DESIGN... UNKNOWN */ );
1815 // HID_APP_REPORT_TREE
1817 else
1819 // as long as we don't get a Frame, we send the user event again.
1820 getView()->PostUserEvent(LINK(this, OReportController, OnOpenHelpAgent));
1823 // -----------------------------------------------------------------------------
1824 sal_Bool OReportController::Construct(Window* pParent)
1826 m_pMyOwnView = new ODesignView(pParent,getORB(),*this);
1827 StartListening(*(m_pMyOwnView));
1828 m_pView = m_pMyOwnView;
1830 // now that we have a view we can create the clipboard listener
1831 m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
1832 m_aSystemClipboard.StartClipboardListening( );
1833 m_pClipbordNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) );
1834 m_pClipbordNotifier->acquire();
1835 m_pClipbordNotifier->AddRemoveListener( getView(), sal_True );
1837 OReportController_BASE::Construct(pParent);
1838 //getView()->Show();
1839 return sal_True;
1841 // -----------------------------------------------------------------------------
1842 sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/) throw( RuntimeException )
1844 if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
1845 return sal_True;
1847 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1848 ::osl::MutexGuard aGuard( getMutex() );
1850 if ( getView() && getView()->IsInModalMode() )
1851 return sal_False;
1853 // this suspend will be handled in the DBAccess interceptor implementation
1854 return sal_True;
1856 // -----------------------------------------------------------------------------
1857 void OReportController::describeSupportedFeatures()
1859 OSingleDocumentController::describeSupportedFeatures();
1861 implDescribeSupportedFeature( ".uno:TextDocument", SID_RPT_TEXTDOCUMENT, CommandGroup::APPLICATION );
1862 implDescribeSupportedFeature( ".uno:Spreadsheet", SID_RPT_SPREADSHEET, CommandGroup::APPLICATION );
1864 implDescribeSupportedFeature( ".uno:Redo", SID_REDO, CommandGroup::EDIT );
1865 implDescribeSupportedFeature( ".uno:Undo", SID_UNDO, CommandGroup::EDIT );
1866 //implDescribeSupportedFeature( ".uno:PasteSpecial", SID_PASTE, CommandGroup::EDIT );
1867 implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
1868 implDescribeSupportedFeature( ".uno:SelectAllInSection", SID_SELECTALL_IN_SECTION, CommandGroup::EDIT );
1869 implDescribeSupportedFeature( ".uno:Delete", SID_DELETE, CommandGroup::EDIT );
1870 implDescribeSupportedFeature( ".uno:SelectReport", SID_SELECT_REPORT, CommandGroup::EDIT );
1871 implDescribeSupportedFeature( ".uno:ExecuteReport", SID_EXECUTE_REPORT, CommandGroup::EDIT );
1873 implDescribeSupportedFeature( ".uno:GridVisible", SID_GRID_VISIBLE, CommandGroup::VIEW );
1874 implDescribeSupportedFeature( ".uno:GridUse", SID_GRID_USE, CommandGroup::VIEW );
1875 implDescribeSupportedFeature( ".uno:HelplinesMove", SID_HELPLINES_MOVE, CommandGroup::VIEW );
1876 implDescribeSupportedFeature( ".uno:ShowRuler", SID_RULER, CommandGroup::VIEW );
1877 implDescribeSupportedFeature( ".uno:AddField", SID_FM_ADD_FIELD, CommandGroup::VIEW );
1878 implDescribeSupportedFeature( ".uno:ReportNavigator", SID_RPT_SHOWREPORTEXPLORER, CommandGroup::VIEW );
1879 implDescribeSupportedFeature( ".uno:ControlProperties", SID_SHOW_PROPERTYBROWSER, CommandGroup::VIEW );
1880 //implDescribeSupportedFeature( ".uno:SwitchControlDesignMode", SID_FM_DESIGN_MODE, CommandGroup::VIEW );
1881 implDescribeSupportedFeature( ".uno:DbSortingAndGrouping", SID_SORTINGANDGROUPING, CommandGroup::VIEW );
1882 implDescribeSupportedFeature( ".uno:PageHeaderFooter", SID_PAGEHEADERFOOTER, CommandGroup::VIEW );
1883 implDescribeSupportedFeature( ".uno:ReportHeaderFooter", SID_REPORTHEADERFOOTER, CommandGroup::VIEW );
1884 implDescribeSupportedFeature( ".uno:ZoomSlider", SID_ATTR_ZOOMSLIDER, CommandGroup::VIEW );
1885 implDescribeSupportedFeature( ".uno:Zoom", SID_ATTR_ZOOM, CommandGroup::VIEW );
1886 //implDescribeSupportedFeature( ".uno:SwitchControlDesignMode", SID_FM_DESIGN_MODE, CommandGroup::VIEW );
1888 implDescribeSupportedFeature( ".uno:ConditionalFormatting", SID_CONDITIONALFORMATTING, CommandGroup::FORMAT );
1889 implDescribeSupportedFeature( ".uno:PageDialog", SID_PAGEDIALOG, CommandGroup::FORMAT );
1890 implDescribeSupportedFeature( ".uno:ResetAttributes", SID_SETCONTROLDEFAULTS, CommandGroup::FORMAT );
1892 implDescribeSupportedFeature( ".uno:Bold", SID_ATTR_CHAR_WEIGHT, CommandGroup::FORMAT );
1893 implDescribeSupportedFeature( ".uno:Italic", SID_ATTR_CHAR_POSTURE, CommandGroup::FORMAT );
1894 implDescribeSupportedFeature( ".uno:Underline", SID_ATTR_CHAR_UNDERLINE, CommandGroup::FORMAT );
1895 implDescribeSupportedFeature( ".uno:BackColor", SID_ATTR_CHAR_COLOR_BACKGROUND, CommandGroup::FORMAT );
1896 implDescribeSupportedFeature( ".uno:BackgroundColor", SID_BACKGROUND_COLOR, CommandGroup::FORMAT );
1897 implDescribeSupportedFeature( ".uno:Color", SID_ATTR_CHAR_COLOR);
1898 implDescribeSupportedFeature( ".uno:FontColor", SID_ATTR_CHAR_COLOR2, CommandGroup::FORMAT );
1899 implDescribeSupportedFeature( ".uno:FontDialog", SID_CHAR_DLG, CommandGroup::FORMAT );
1900 implDescribeSupportedFeature( ".uno:LeftPara", SID_ATTR_PARA_ADJUST_LEFT, CommandGroup::FORMAT );
1901 implDescribeSupportedFeature( ".uno:CenterPara", SID_ATTR_PARA_ADJUST_CENTER, CommandGroup::FORMAT );
1902 implDescribeSupportedFeature( ".uno:RightPara", SID_ATTR_PARA_ADJUST_RIGHT, CommandGroup::FORMAT );
1903 implDescribeSupportedFeature( ".uno:JustifyPara", SID_ATTR_PARA_ADJUST_BLOCK, CommandGroup::FORMAT );
1905 implDescribeSupportedFeature( ".uno:FontHeight", SID_ATTR_CHAR_FONTHEIGHT, CommandGroup::FORMAT );
1906 implDescribeSupportedFeature( ".uno:CharFontName", SID_ATTR_CHAR_FONT, CommandGroup::FORMAT );
1908 implDescribeSupportedFeature( ".uno:ArrangeMenu", SID_ARRANGEMENU, CommandGroup::FORMAT );
1909 implDescribeSupportedFeature( ".uno:BringToFront", SID_FRAME_TO_TOP, CommandGroup::FORMAT );
1910 implDescribeSupportedFeature( ".uno:ObjectBackOne", SID_FRAME_DOWN, CommandGroup::FORMAT );
1911 implDescribeSupportedFeature( ".uno:ObjectForwardOne", SID_FRAME_UP, CommandGroup::FORMAT );
1912 implDescribeSupportedFeature( ".uno:SendToBack", SID_FRAME_TO_BOTTOM, CommandGroup::FORMAT );
1913 implDescribeSupportedFeature( ".uno:SetObjectToForeground", SID_OBJECT_HEAVEN, CommandGroup::FORMAT );
1914 implDescribeSupportedFeature( ".uno:SetObjectToBackground", SID_OBJECT_HELL, CommandGroup::FORMAT );
1916 implDescribeSupportedFeature( ".uno:ObjectAlign", SID_OBJECT_ALIGN, CommandGroup::FORMAT );
1917 implDescribeSupportedFeature( ".uno:ObjectAlignLeft", SID_OBJECT_ALIGN_LEFT, CommandGroup::FORMAT );
1918 implDescribeSupportedFeature( ".uno:AlignCenter", SID_OBJECT_ALIGN_CENTER, CommandGroup::FORMAT );
1919 implDescribeSupportedFeature( ".uno:ObjectAlignRight", SID_OBJECT_ALIGN_RIGHT, CommandGroup::FORMAT );
1920 implDescribeSupportedFeature( ".uno:AlignUp", SID_OBJECT_ALIGN_UP, CommandGroup::FORMAT );
1921 implDescribeSupportedFeature( ".uno:AlignMiddle", SID_OBJECT_ALIGN_MIDDLE, CommandGroup::FORMAT );
1922 implDescribeSupportedFeature( ".uno:AlignDown", SID_OBJECT_ALIGN_DOWN, CommandGroup::FORMAT );
1924 implDescribeSupportedFeature( ".uno:SectionAlign", SID_SECTION_ALIGN, CommandGroup::FORMAT );
1925 implDescribeSupportedFeature( ".uno:SectionAlignLeft", SID_SECTION_ALIGN_LEFT, CommandGroup::FORMAT );
1926 implDescribeSupportedFeature( ".uno:SectionAlignCenter", SID_SECTION_ALIGN_CENTER, CommandGroup::FORMAT );
1927 implDescribeSupportedFeature( ".uno:SectionAlignRight", SID_SECTION_ALIGN_RIGHT, CommandGroup::FORMAT );
1928 implDescribeSupportedFeature( ".uno:SectionAlignTop", SID_SECTION_ALIGN_UP, CommandGroup::FORMAT );
1929 implDescribeSupportedFeature( ".uno:SectionAlignMiddle", SID_SECTION_ALIGN_MIDDLE, CommandGroup::FORMAT );
1930 implDescribeSupportedFeature( ".uno:SectionAlignBottom", SID_SECTION_ALIGN_DOWN, CommandGroup::FORMAT );
1931 implDescribeSupportedFeature( ".uno:SectionShrink", SID_SECTION_SHRINK, CommandGroup::FORMAT );
1932 implDescribeSupportedFeature( ".uno:SectionShrinkTop", SID_SECTION_SHRINK_TOP, CommandGroup::FORMAT );
1933 implDescribeSupportedFeature( ".uno:SectionShrinkBottom", SID_SECTION_SHRINK_BOTTOM, CommandGroup::FORMAT );
1935 implDescribeSupportedFeature( ".uno:ObjectResize", SID_OBJECT_RESIZING, CommandGroup::FORMAT );
1936 implDescribeSupportedFeature( ".uno:SmallestWidth", SID_OBJECT_SMALLESTWIDTH, CommandGroup::FORMAT );
1937 implDescribeSupportedFeature( ".uno:SmallestHeight", SID_OBJECT_SMALLESTHEIGHT, CommandGroup::FORMAT );
1938 implDescribeSupportedFeature( ".uno:GreatestWidth", SID_OBJECT_GREATESTWIDTH, CommandGroup::FORMAT );
1939 implDescribeSupportedFeature( ".uno:GreatestHeight", SID_OBJECT_GREATESTHEIGHT, CommandGroup::FORMAT );
1940 implDescribeSupportedFeature( ".uno:Distribution", SID_DISTRIBUTION, CommandGroup::FORMAT );
1942 implDescribeSupportedFeature( ".uno:HelpMenu", SID_HELPMENU, CommandGroup::APPLICATION );
1943 implDescribeSupportedFeature( ".uno:ExportTo", SID_EXPORTDOC, CommandGroup::APPLICATION );
1944 implDescribeSupportedFeature( ".uno:ExportToPDF", SID_EXPORTDOCASPDF, CommandGroup::APPLICATION );
1945 implDescribeSupportedFeature( ".uno:PrintPreview", SID_PRINTPREVIEW, CommandGroup::APPLICATION );
1947 implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
1948 implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT );
1949 implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT );
1951 implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT );
1952 implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT );
1953 implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT );
1954 implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT );
1955 // controls
1956 implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT );
1957 implDescribeSupportedFeature( ".uno:Label", SID_FM_FIXEDTEXT, CommandGroup::INSERT );
1958 implDescribeSupportedFeature( ".uno:Edit", SID_FM_EDIT, CommandGroup::INSERT );
1959 implDescribeSupportedFeature( ".uno:ImageControl", SID_FM_IMAGECONTROL, CommandGroup::INSERT );
1960 implDescribeSupportedFeature( ".uno:HFixedLine", SID_INSERT_HFIXEDLINE, CommandGroup::INSERT );
1961 implDescribeSupportedFeature( ".uno:VFixedLine", SID_INSERT_VFIXEDLINE, CommandGroup::INSERT );
1963 // shapes
1964 implDescribeSupportedFeature( ".uno:BasicShapes", SID_DRAWTBX_CS_BASIC, CommandGroup::INSERT );
1965 implDescribeSupportedFeature( ".uno:BasicShapes.rectangle", SID_DRAWTBX_CS_BASIC1, CommandGroup::INSERT );
1966 implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2, CommandGroup::INSERT );
1967 implDescribeSupportedFeature( ".uno:BasicShapes.quadrat", SID_DRAWTBX_CS_BASIC3, CommandGroup::INSERT );
1968 implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4, CommandGroup::INSERT );
1969 implDescribeSupportedFeature( ".uno:BasicShapes.circle", SID_DRAWTBX_CS_BASIC5, CommandGroup::INSERT );
1970 implDescribeSupportedFeature( ".uno:BasicShapes.ellipse", SID_DRAWTBX_CS_BASIC6, CommandGroup::INSERT );
1971 implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie", SID_DRAWTBX_CS_BASIC7, CommandGroup::INSERT );
1972 implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8, CommandGroup::INSERT );
1973 implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9, CommandGroup::INSERT );
1974 implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid", SID_DRAWTBX_CS_BASIC10, CommandGroup::INSERT );
1975 implDescribeSupportedFeature( ".uno:BasicShapes.diamond", SID_DRAWTBX_CS_BASIC11, CommandGroup::INSERT );
1976 implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12, CommandGroup::INSERT );
1977 implDescribeSupportedFeature( ".uno:BasicShapes.pentagon", SID_DRAWTBX_CS_BASIC13, CommandGroup::INSERT );
1978 implDescribeSupportedFeature( ".uno:BasicShapes.hexagon", SID_DRAWTBX_CS_BASIC14, CommandGroup::INSERT );
1979 implDescribeSupportedFeature( ".uno:BasicShapes.octagon", SID_DRAWTBX_CS_BASIC15, CommandGroup::INSERT );
1980 implDescribeSupportedFeature( ".uno:BasicShapes.cross", SID_DRAWTBX_CS_BASIC16, CommandGroup::INSERT );
1981 implDescribeSupportedFeature( ".uno:BasicShapes.ring", SID_DRAWTBX_CS_BASIC17, CommandGroup::INSERT );
1982 implDescribeSupportedFeature( ".uno:BasicShapes.block-arc", SID_DRAWTBX_CS_BASIC18, CommandGroup::INSERT );
1983 implDescribeSupportedFeature( ".uno:BasicShapes.can", SID_DRAWTBX_CS_BASIC19, CommandGroup::INSERT );
1984 implDescribeSupportedFeature( ".uno:BasicShapes.cube", SID_DRAWTBX_CS_BASIC20, CommandGroup::INSERT );
1985 implDescribeSupportedFeature( ".uno:BasicShapes.paper", SID_DRAWTBX_CS_BASIC21, CommandGroup::INSERT );
1986 implDescribeSupportedFeature( ".uno:BasicShapes.frame", SID_DRAWTBX_CS_BASIC22, CommandGroup::INSERT );
1988 implDescribeSupportedFeature( ".uno:SymbolShapes", SID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT );
1990 implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" , SID_DRAWTBX_CS_SYMBOL1, CommandGroup::INSERT );
1991 implDescribeSupportedFeature( ".uno:SymbolShapes.sun" , SID_DRAWTBX_CS_SYMBOL2, CommandGroup::INSERT );
1992 implDescribeSupportedFeature( ".uno:SymbolShapes.moon" , SID_DRAWTBX_CS_SYMBOL3, CommandGroup::INSERT );
1993 implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" , SID_DRAWTBX_CS_SYMBOL4, CommandGroup::INSERT );
1994 implDescribeSupportedFeature( ".uno:SymbolShapes.heart" , SID_DRAWTBX_CS_SYMBOL5, CommandGroup::INSERT );
1995 implDescribeSupportedFeature( ".uno:SymbolShapes.flower" , SID_DRAWTBX_CS_SYMBOL6, CommandGroup::INSERT );
1996 implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" , SID_DRAWTBX_CS_SYMBOL7, CommandGroup::INSERT );
1997 implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" , SID_DRAWTBX_CS_SYMBOL8, CommandGroup::INSERT );
1998 implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" , SID_DRAWTBX_CS_SYMBOL9, CommandGroup::INSERT );
1999 implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10, CommandGroup::INSERT );
2000 implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11, CommandGroup::INSERT );
2001 implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12, CommandGroup::INSERT );
2002 implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" , SID_DRAWTBX_CS_SYMBOL13, CommandGroup::INSERT );
2003 implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" , SID_DRAWTBX_CS_SYMBOL14, CommandGroup::INSERT );
2004 implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" , SID_DRAWTBX_CS_SYMBOL15, CommandGroup::INSERT );
2005 implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" , SID_DRAWTBX_CS_SYMBOL16, CommandGroup::INSERT );
2006 implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17, CommandGroup::INSERT );
2007 implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18, CommandGroup::INSERT );
2009 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" , SID_DRAWTBX_CS_ARROW1, CommandGroup::INSERT );
2010 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" , SID_DRAWTBX_CS_ARROW2, CommandGroup::INSERT );
2011 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" , SID_DRAWTBX_CS_ARROW3, CommandGroup::INSERT );
2012 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" , SID_DRAWTBX_CS_ARROW4, CommandGroup::INSERT );
2013 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" , SID_DRAWTBX_CS_ARROW5, CommandGroup::INSERT );
2014 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" , SID_DRAWTBX_CS_ARROW6, CommandGroup::INSERT );
2015 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" , SID_DRAWTBX_CS_ARROW7, CommandGroup::INSERT );
2016 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" , SID_DRAWTBX_CS_ARROW8, CommandGroup::INSERT );
2017 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" , SID_DRAWTBX_CS_ARROW9, CommandGroup::INSERT );
2018 implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" , SID_DRAWTBX_CS_ARROW10, CommandGroup::INSERT );
2019 implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" , SID_DRAWTBX_CS_ARROW11, CommandGroup::INSERT );
2020 implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" , SID_DRAWTBX_CS_ARROW12, CommandGroup::INSERT );
2021 implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" , SID_DRAWTBX_CS_ARROW13, CommandGroup::INSERT );
2022 implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" , SID_DRAWTBX_CS_ARROW14, CommandGroup::INSERT );
2023 implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" , SID_DRAWTBX_CS_ARROW15, CommandGroup::INSERT );
2024 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" , SID_DRAWTBX_CS_ARROW16, CommandGroup::INSERT );
2025 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" , SID_DRAWTBX_CS_ARROW17, CommandGroup::INSERT );
2026 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" , SID_DRAWTBX_CS_ARROW18, CommandGroup::INSERT );
2027 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" , SID_DRAWTBX_CS_ARROW19, CommandGroup::INSERT );
2028 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20, CommandGroup::INSERT );
2029 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21, CommandGroup::INSERT );
2030 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22, CommandGroup::INSERT );
2031 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" , SID_DRAWTBX_CS_ARROW23, CommandGroup::INSERT );
2032 implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" , SID_DRAWTBX_CS_ARROW24, CommandGroup::INSERT );
2033 implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" , SID_DRAWTBX_CS_ARROW25, CommandGroup::INSERT );
2034 implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" , SID_DRAWTBX_CS_ARROW26, CommandGroup::INSERT );
2036 implDescribeSupportedFeature( ".uno:StarShapes.bang" , SID_DRAWTBX_CS_STAR1, CommandGroup::INSERT );
2037 implDescribeSupportedFeature( ".uno:StarShapes.star4" , SID_DRAWTBX_CS_STAR2, CommandGroup::INSERT );
2038 implDescribeSupportedFeature( ".uno:StarShapes.star5" , SID_DRAWTBX_CS_STAR3, CommandGroup::INSERT );
2039 implDescribeSupportedFeature( ".uno:StarShapes.star6" , SID_DRAWTBX_CS_STAR4, CommandGroup::INSERT );
2040 implDescribeSupportedFeature( ".uno:StarShapes.star8" , SID_DRAWTBX_CS_STAR5, CommandGroup::INSERT );
2041 implDescribeSupportedFeature( ".uno:StarShapes.star12" , SID_DRAWTBX_CS_STAR6, CommandGroup::INSERT );
2042 implDescribeSupportedFeature( ".uno:StarShapes.star24" , SID_DRAWTBX_CS_STAR7, CommandGroup::INSERT );
2043 implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" , SID_DRAWTBX_CS_STAR8, CommandGroup::INSERT );
2044 implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" , SID_DRAWTBX_CS_STAR9, CommandGroup::INSERT );
2045 implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" , SID_DRAWTBX_CS_STAR10, CommandGroup::INSERT );
2046 implDescribeSupportedFeature( ".uno:StarShapes.signet" , SID_DRAWTBX_CS_STAR11, CommandGroup::INSERT );
2047 implDescribeSupportedFeature( ".uno:StarShapes.doorplate" , SID_DRAWTBX_CS_STAR12, CommandGroup::INSERT );
2049 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" , SID_DRAWTBX_CS_FLOWCHART1, CommandGroup::INSERT );
2050 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" , SID_DRAWTBX_CS_FLOWCHART2, CommandGroup::INSERT );
2051 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" , SID_DRAWTBX_CS_FLOWCHART3, CommandGroup::INSERT );
2052 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" , SID_DRAWTBX_CS_FLOWCHART4, CommandGroup::INSERT );
2053 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" , SID_DRAWTBX_CS_FLOWCHART5, CommandGroup::INSERT );
2054 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" , SID_DRAWTBX_CS_FLOWCHART6, CommandGroup::INSERT );
2055 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" , SID_DRAWTBX_CS_FLOWCHART7, CommandGroup::INSERT );
2056 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" , SID_DRAWTBX_CS_FLOWCHART8, CommandGroup::INSERT );
2057 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" , SID_DRAWTBX_CS_FLOWCHART9, CommandGroup::INSERT );
2058 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" , SID_DRAWTBX_CS_FLOWCHART10, CommandGroup::INSERT );
2059 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" , SID_DRAWTBX_CS_FLOWCHART11, CommandGroup::INSERT );
2060 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" , SID_DRAWTBX_CS_FLOWCHART12, CommandGroup::INSERT );
2061 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" , SID_DRAWTBX_CS_FLOWCHART13, CommandGroup::INSERT );
2062 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" , SID_DRAWTBX_CS_FLOWCHART14, CommandGroup::INSERT );
2063 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" , SID_DRAWTBX_CS_FLOWCHART15, CommandGroup::INSERT );
2064 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" , SID_DRAWTBX_CS_FLOWCHART16, CommandGroup::INSERT );
2065 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" , SID_DRAWTBX_CS_FLOWCHART17, CommandGroup::INSERT );
2066 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" , SID_DRAWTBX_CS_FLOWCHART18, CommandGroup::INSERT );
2067 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" , SID_DRAWTBX_CS_FLOWCHART19, CommandGroup::INSERT );
2068 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" , SID_DRAWTBX_CS_FLOWCHART20, CommandGroup::INSERT );
2069 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" , SID_DRAWTBX_CS_FLOWCHART21, CommandGroup::INSERT );
2070 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" , SID_DRAWTBX_CS_FLOWCHART22, CommandGroup::INSERT );
2071 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" , SID_DRAWTBX_CS_FLOWCHART23, CommandGroup::INSERT );
2072 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" , SID_DRAWTBX_CS_FLOWCHART24, CommandGroup::INSERT );
2073 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" , SID_DRAWTBX_CS_FLOWCHART25, CommandGroup::INSERT );
2074 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" , SID_DRAWTBX_CS_FLOWCHART26, CommandGroup::INSERT );
2075 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27, CommandGroup::INSERT );
2076 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" , SID_DRAWTBX_CS_FLOWCHART28, CommandGroup::INSERT );
2078 implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" , SID_DRAWTBX_CS_CALLOUT1, CommandGroup::INSERT );
2079 implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" , SID_DRAWTBX_CS_CALLOUT2, CommandGroup::INSERT );
2080 implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" , SID_DRAWTBX_CS_CALLOUT3, CommandGroup::INSERT );
2081 implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" , SID_DRAWTBX_CS_CALLOUT4, CommandGroup::INSERT );
2082 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" , SID_DRAWTBX_CS_CALLOUT5, CommandGroup::INSERT );
2083 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" , SID_DRAWTBX_CS_CALLOUT6, CommandGroup::INSERT );
2084 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" , SID_DRAWTBX_CS_CALLOUT7, CommandGroup::INSERT );
2086 implDescribeSupportedFeature( ".uno:ArrowShapes", SID_DRAWTBX_CS_ARROW, CommandGroup::INSERT );
2088 implDescribeSupportedFeature( ".uno:FlowChartShapes", SID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT );
2089 implDescribeSupportedFeature( ".uno:CalloutShapes", SID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT );
2090 implDescribeSupportedFeature( ".uno:StarShapes", SID_DRAWTBX_CS_STAR, CommandGroup::INSERT );
2093 // keys
2094 implDescribeSupportedFeature( ".uno:Escape", SID_ESCAPE, CommandGroup::CONTROLS);
2096 // internal one
2097 implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO", SID_REPORTHEADER_WITHOUT_UNDO);
2098 implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO", SID_REPORTFOOTER_WITHOUT_UNDO);
2099 implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO", SID_PAGEHEADER_WITHOUT_UNDO);
2100 implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO", SID_PAGEFOOTER_WITHOUT_UNDO);
2101 implDescribeSupportedFeature( ".uno:DBBackgroundColor", SID_ATTR_CHAR_COLOR_BACKGROUND);
2102 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER", SID_GROUPHEADER);
2103 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO", SID_GROUPHEADER_WITHOUT_UNDO);
2104 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER", SID_GROUPFOOTER);
2105 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO", SID_GROUPFOOTER_WITHOUT_UNDO);
2106 implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE", SID_GROUP_REMOVE);
2107 implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND", SID_GROUP_APPEND);
2108 implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR", SID_ADD_CONTROL_PAIR);
2109 implDescribeSupportedFeature( ".uno:SplitPosition", SID_SPLIT_POSITION);
2110 implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage", SID_PROPERTYBROWSER_LAST_PAGE);
2111 implDescribeSupportedFeature( ".uno:Select", SID_SELECT);
2112 implDescribeSupportedFeature( ".uno:InsertFunction", SID_RPT_NEW_FUNCTION);
2113 implDescribeSupportedFeature( ".uno:NextMark", SID_NEXT_MARK);
2114 implDescribeSupportedFeature( ".uno:PrevMark", SID_PREV_MARK);
2115 implDescribeSupportedFeature( ".uno:TerminateInplaceActivation", SID_TERMINATE_INPLACEACTIVATION);
2116 implDescribeSupportedFeature( ".uno:SelectAllLabels", SID_SELECT_ALL_LABELS);
2117 implDescribeSupportedFeature( ".uno:SelectAllEdits", SID_SELECT_ALL_EDITS);
2118 implDescribeSupportedFeature( ".uno:CollapseSection", SID_COLLAPSE_SECTION);
2119 implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION);
2121 // -----------------------------------------------------------------------------
2122 SfxUndoManager* OReportController::getUndoMgr()
2124 return &m_aUndoManager;
2126 // -----------------------------------------------------------------------------
2127 void OReportController::setModified(sal_Bool _bModified)
2129 ::osl::MutexGuard aGuard( getMutex() );
2132 if ( m_xReportDefinition.is() )
2133 m_xReportDefinition->setModified(_bModified);
2134 OSingleDocumentController::setModified(_bModified);
2136 catch(uno::Exception)
2139 // -----------------------------------------------------------------------------
2140 void OReportController::losingConnection( )
2142 // let the base class do it's reconnect
2143 OReportController_BASE::losingConnection( );
2145 InvalidateAll();
2147 // -----------------------------------------------------------------------------
2148 void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager)
2150 if ( _xLayoutManager.is() )
2152 static const ::rtl::OUString s_sMenu[] = {
2153 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/statusbar/statusbar"))
2154 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/reportcontrols"))
2155 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/drawbar"))
2156 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/Formatting"))
2157 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/alignmentbar"))
2158 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionalignmentbar"))
2159 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/resizebar"))
2160 ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:resource/toolbar/sectionshrinkbar"))
2162 for (size_t i = 0; i< sizeof(s_sMenu)/sizeof(s_sMenu[0]); ++i)
2164 _xLayoutManager->createElement( s_sMenu[i] );
2165 _xLayoutManager->requestElement( s_sMenu[i] );
2167 } // if ( _xLayoutManager.is() )
2169 // -----------------------------------------------------------------------------
2170 void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow)
2172 uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY);
2173 if ( xGroup.is() )
2175 ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
2176 ::osl::MutexGuard aGuard( getMutex() );
2177 sal_Int32 nGroupPos = 0;
2178 _rEvent.Accessor >>= nGroupPos;
2180 if ( _bShow )
2182 xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2183 xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2185 else
2187 xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2188 xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2191 if ( xGroup->getHeaderOn() )
2193 groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow);
2194 if (_bShow)
2196 m_pReportControllerObserver->AddSection(xGroup->getHeader());
2198 else
2200 m_pReportControllerObserver->RemoveSection(xGroup->getHeader());
2203 if ( xGroup->getFooterOn() )
2205 groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow);
2206 if (_bShow)
2208 m_pReportControllerObserver->AddSection(xGroup->getFooter());
2210 else
2212 m_pReportControllerObserver->RemoveSection(xGroup->getFooter());
2217 // -----------------------------------------------------------------------------
2218 // ::container::XContainerListener
2219 void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException)
2221 notifyGroupSections(_rEvent,true);
2223 // -----------------------------------------------------------------------------
2224 void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException)
2226 notifyGroupSections(_rEvent,false);
2228 // -----------------------------------------------------------------------------
2229 void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ ) throw(RuntimeException)
2231 ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
2232 ::osl::MutexGuard aGuard( getMutex() );
2233 OSL_ENSURE(0,"Not yet implemented!");
2235 // -----------------------------------------------------------------------------
2236 void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt ) throw (RuntimeException)
2238 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
2239 ::osl::MutexGuard aGuard( getMutex() );
2242 sal_Bool bShow = sal_False;
2243 evt.NewValue >>= bShow;
2244 if ( evt.Source == m_xReportDefinition )
2246 if ( evt.PropertyName.equals( PROPERTY_REPORTHEADERON ) )
2248 const USHORT nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0;
2249 if ( bShow )
2251 m_pMyOwnView->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition);
2252 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader());
2254 else
2256 m_pMyOwnView->removeSection(nPosition);
2259 else if ( evt.PropertyName.equals( PROPERTY_REPORTFOOTERON ) )
2261 USHORT nPosition = m_pMyOwnView->getSectionCount();
2262 if ( m_xReportDefinition->getPageFooterOn() )
2263 --nPosition;
2264 if ( bShow )
2266 m_pMyOwnView->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition);
2267 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter());
2269 else
2271 m_pMyOwnView->removeSection(nPosition - 1);
2274 else if ( evt.PropertyName.equals( PROPERTY_PAGEHEADERON ) )
2276 if ( bShow )
2278 m_pMyOwnView->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0);
2279 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader());
2281 else
2283 m_pMyOwnView->removeSection(USHORT(0));
2286 else if ( evt.PropertyName.equals( PROPERTY_PAGEFOOTERON ) )
2288 if ( bShow )
2290 m_pMyOwnView->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
2291 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter());
2293 else
2295 m_pMyOwnView->removeSection(m_pMyOwnView->getSectionCount() - 1);
2298 else if ( evt.PropertyName.equals( PROPERTY_COMMAND )
2299 || evt.PropertyName.equals( PROPERTY_COMMANDTYPE )
2300 || evt.PropertyName.equals( PROPERTY_ESCAPEPROCESSING )
2301 || evt.PropertyName.equals( PROPERTY_FILTER )
2304 InvalidateFeature(SID_FM_ADD_FIELD);
2305 if ( !m_pMyOwnView->isAddFieldVisible() && isUiVisible() )
2306 m_pMyOwnView->toggleAddField();
2308 /// TODO: check what we need to notify here TitleHelper
2309 /*else if ( evt.PropertyName.equals( PROPERTY_CAPTION ) )
2310 updateTitle();*/
2311 } // if ( evt.Source == m_xReportDefinition )
2312 else
2314 uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY);
2315 if ( xGroup.is() )
2317 sal_Int32 nGroupPos = getGroupPosition(xGroup);
2319 groupChange(xGroup,evt.PropertyName,nGroupPos,bShow);
2323 catch(const uno::Exception&)
2325 DBG_UNHANDLED_EXCEPTION();
2329 // -----------------------------------------------------------------------------
2330 void SAL_CALL OReportController::disposing( const lang::EventObject& Source ) throw(uno::RuntimeException)
2332 OReportController_BASE::disposing(Source);
2335 // -----------------------------------------------------------------------------
2336 USHORT lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups
2337 ,sal_Int32 _nGroupPos
2338 ,::std::mem_fun_t<sal_Bool,OGroupHelper>&_pGroupMemberFunction)
2340 uno::Reference< report::XGroup> xGroup;
2341 USHORT nNonVisibleGroups = 0;
2342 sal_Int32 nCount = _xGroups->getCount();
2343 for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i)
2345 xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY);
2346 OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF");
2347 OGroupHelper aGroupHelper(xGroup);
2348 if ( !_pGroupMemberFunction(&aGroupHelper) )
2349 ++nNonVisibleGroups;
2351 return nNonVisibleGroups;
2353 // -----------------------------------------------------------------------------
2354 void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const ::rtl::OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow)
2356 //adjustSectionName(_xGroup,_nGroupPos);
2357 ::std::mem_fun_t<sal_Bool,OGroupHelper> pMemFun = ::std::mem_fun(&OGroupHelper::getHeaderOn);
2358 ::std::mem_fun_t<uno::Reference<report::XSection> , OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader);
2359 ::rtl::OUString sColor(DBGROUPHEADER);
2360 USHORT nPosition = 0;
2361 bool bHandle = false;
2362 if ( _sPropName.equals( PROPERTY_HEADERON ) )
2364 nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0);
2365 nPosition += (static_cast<USHORT>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2366 bHandle = true;
2368 else if ( _sPropName.equals( PROPERTY_FOOTERON ) )
2370 pMemFun = ::std::mem_fun(&OGroupHelper::getFooterOn);
2371 pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter);
2372 nPosition = m_pMyOwnView->getSectionCount();
2374 if ( m_xReportDefinition->getPageFooterOn() )
2375 --nPosition;
2376 if ( m_xReportDefinition->getReportFooterOn() )
2377 --nPosition;
2378 sColor = DBGROUPFOOTER;
2379 nPosition -= (static_cast<USHORT>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2380 if ( !_bShow )
2381 --nPosition;
2382 bHandle = true;
2384 if ( bHandle )
2386 if ( _bShow )
2388 OGroupHelper aGroupHelper(_xGroup);
2389 m_pMyOwnView->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition);
2391 else
2393 m_pMyOwnView->removeSection(nPosition);
2397 //------------------------------------------------------------------------------
2398 IMPL_LINK( OReportController, OnClipboardChanged, void*, EMPTYARG )
2400 return OnInvalidateClipboard( NULL );
2402 //------------------------------------------------------------------------------
2403 IMPL_LINK( OReportController, NotifyUndoActionHdl, SfxUndoAction*, _pUndoAction )
2405 OSL_ENSURE(_pUndoAction,"UndoAction is NULL!");
2406 addUndoActionAndInvalidate(_pUndoAction);
2407 return 0L;
2409 //------------------------------------------------------------------------------
2410 IMPL_LINK(OReportController, OnInvalidateClipboard, void*, EMPTYARG)
2412 InvalidateFeature(SID_CUT);
2413 InvalidateFeature(SID_COPY);
2414 InvalidateFeature(SID_PASTE);
2415 return 0L;
2417 // -----------------------------------------------------------------------------
2418 void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection)
2420 if ( !m_xReportDefinition.is() )
2421 return;
2422 // ------------
2423 // UNO->ItemSet
2424 static SfxItemInfo aItemInfos[] =
2426 { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE },
2427 { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE },
2428 { SID_ATTR_PAGE, SFX_ITEM_POOLABLE },
2429 { SID_ATTR_PAGE_SIZE, SFX_ITEM_POOLABLE },
2430 { SID_ENUM_PAGE_MODE, SFX_ITEM_POOLABLE },
2431 { SID_PAPER_START, SFX_ITEM_POOLABLE },
2432 { SID_PAPER_END, SFX_ITEM_POOLABLE },
2433 { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE },
2434 { SID_FLAG_TYPE, SFX_ITEM_POOLABLE },
2435 { SID_ATTR_METRIC, SFX_ITEM_POOLABLE }
2438 MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
2439 FieldUnit eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
2440 SfxPoolItem* pDefaults[] =
2442 new SvxLRSpaceItem(RPTUI_ID_LRSPACE),
2443 new SvxULSpaceItem(RPTUI_ID_ULSPACE),
2444 new SvxPageItem(RPTUI_ID_PAGE),
2445 new SvxSizeItem(RPTUI_ID_SIZE),
2446 new SfxAllEnumItem(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD),
2447 new SfxAllEnumItem(RPTUI_ID_START,PAPER_A4),
2448 new SfxAllEnumItem(RPTUI_ID_END,PAPER_E),
2449 new SvxBrushItem(ITEMID_BRUSH),
2450 new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<UINT16>(eUserMetric))
2453 static USHORT pRanges[] =
2455 RPTUI_ID_LRSPACE,RPTUI_ID_BRUSH,
2456 SID_ATTR_METRIC,SID_ATTR_METRIC,
2459 SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ReportPageProperties"), RPTUI_ID_LRSPACE,RPTUI_ID_METRIC, aItemInfos, pDefaults) );
2460 pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why
2461 pPool->FreezeIdRanges(); // the same
2465 ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
2466 // fill it
2467 if ( _xSection.is() )
2468 pDescriptor->Put(SvxBrushItem(::Color(_xSection->getBackColor()),ITEMID_BRUSH));
2469 else
2471 pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
2472 pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
2473 ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
2474 pDescriptor->Put(SvxULSpaceItem(static_cast<USHORT>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
2475 ,static_cast<USHORT>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
2476 pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<UINT16>(eUserMetric)));
2478 uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition));
2479 if ( xPageStyle.is() )
2481 SvxPageItem aPageItem(RPTUI_ID_PAGE);
2482 aPageItem.SetDescName(xPageStyle->getName());
2483 uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW);
2484 aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT);
2485 aPageItem.SetLandscape(getStyleProperty<sal_Bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE));
2486 aPageItem.SetNumType((SvxNumType)getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE));
2487 pDescriptor->Put(aPageItem);
2488 pDescriptor->Put(SvxBrushItem(::Color(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH));
2492 { // want the dialog to be destroyed before our set
2493 ORptPageDialog aDlg(getView(), pDescriptor.get(),_xSection.is() ? RID_PAGEDIALOG_BACKGROUND : RID_PAGEDIALOG_PAGE);
2494 if (RET_OK == aDlg.Execute())
2496 // ------------
2497 // ItemSet->UNO
2498 // UNO-properties
2499 const SfxItemSet* pSet = aDlg.GetOutputItemSet();
2500 if ( _xSection.is() )
2502 const SfxPoolItem* pItem;
2503 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem))
2504 _xSection->setBackColor(static_cast<const SvxBrushItem*>(pItem)->GetColor().GetColor());
2506 else
2508 uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW);
2509 const String sUndoAction(ModuleRes(RID_STR_UNDO_CHANGEPAGE));
2510 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
2511 const SfxPoolItem* pItem = NULL;
2512 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_SIZE,sal_True,&pItem))
2514 const Size aPaperSize = static_cast<const SvxSizeItem*>(pItem)->GetSize();
2515 uno::Any aValue;
2516 static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue,MID_SIZE_SIZE);
2517 xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue);
2518 resetZoomType();
2521 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_LRSPACE,sal_True,&pItem))
2523 xProp->setPropertyValue(PROPERTY_LEFTMARGIN,uno::makeAny(static_cast<const SvxLRSpaceItem*>(pItem)->GetLeft()));
2524 xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,uno::makeAny(static_cast<const SvxLRSpaceItem*>(pItem)->GetRight()));
2526 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_ULSPACE,sal_True,&pItem))
2528 xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()));
2529 xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower()));
2531 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_PAGE,sal_True,&pItem))
2533 const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem);
2534 xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(static_cast<sal_Bool>(pPageItem->IsLandscape())));
2535 xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType())));
2536 uno::Any aValue;
2537 pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT);
2538 xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue);
2539 resetZoomType();
2541 if ( SFX_ITEM_SET == pSet->GetItemState( RPTUI_ID_BRUSH,sal_True,&pItem))
2543 ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
2544 xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT));
2545 xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor.GetColor()));
2551 catch(Exception&)
2553 DBG_UNHANDLED_EXCEPTION();
2555 SfxItemPool::Free(pPool);
2557 for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
2558 delete pDefaults[i];
2561 // -----------------------------------------------------------------------------
2562 sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel) throw( uno::RuntimeException )
2564 ::osl::MutexGuard aGuard( getMutex() );
2565 m_xReportDefinition.set(xModel,uno::UNO_QUERY);
2566 return m_xReportDefinition.is();
2568 // -----------------------------------------------------------------------------
2569 void OReportController::openSortingAndGroupingDialog()
2571 if ( !m_xReportDefinition.is() )
2572 return;
2573 if ( !m_pGroupsFloater )
2575 m_pGroupsFloater = new OGroupsSortingDialog(getView(),!isEditable(),this);
2576 SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_GROUPS_SORTING ) );
2577 if ( aDlgOpt.Exists() )
2578 m_pGroupsFloater->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
2579 m_pGroupsFloater->AddEventListener(LINK(this,OReportController,EventLstHdl));
2581 else if ( isUiVisible() )
2582 m_pGroupsFloater->Show(!m_pGroupsFloater->IsVisible());
2584 // -----------------------------------------------------------------------------
2585 sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup)
2587 return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),_xGroup);
2589 // -----------------------------------------------------------------------------
2590 // -----------------------------------------------------------------------------
2591 IMPL_LINK( OReportController, EventLstHdl, VclWindowEvent*, _pEvent )
2593 if ( _pEvent && _pEvent->GetId() == VCLEVENT_WINDOW_CLOSE )
2595 InvalidateFeature(SID_SORTINGANDGROUPING);
2596 InvalidateFeature(SID_FM_ADD_FIELD);
2597 InvalidateFeature(SID_RPT_SHOWREPORTEXPLORER);
2599 return 1L;
2601 // -----------------------------------------------------------------------------
2602 void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint)
2604 if (_rHint.ISA(DlgEdHint)
2605 && (static_cast< DlgEdHint const & >(_rHint).GetKind()
2606 == RPTUI_HINT_SELECTIONCHANGED))
2608 const sal_Int32 nSelectionCount = m_pMyOwnView->getMarkedObjectCount();
2609 if ( m_nSelectionCount != nSelectionCount )
2611 m_nSelectionCount = nSelectionCount;
2612 InvalidateAll();
2614 lang::EventObject aEvent(*this);
2615 m_aSelectionListeners.forEach<view::XSelectionChangeListener>(
2616 ::boost::bind(&view::XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent)));
2619 // if (_rHint.ISA(SfxSimpleHint)
2620 // && (static_cast< SfxSimpleHint const & >(_rHint).GetId()
2621 // == SFX_HINT_COLORS_CHANGED))
2622 // {
2623 // int dummy = 0;
2624 // }
2625 // if (m_pReportControllerObserver)
2626 // {
2627 // m_pReportControllerObserver->Notify(_rBc, _rHint);
2628 // }
2630 // -----------------------------------------------------------------------------
2631 void OReportController::executeMethodWithUndo(USHORT _nUndoStrId,const ::std::mem_fun_t<void,ODesignView>& _pMemfun)
2633 const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2634 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
2635 _pMemfun(m_pMyOwnView);
2636 InvalidateFeature( SID_SAVEDOC );
2637 InvalidateFeature( SID_UNDO );
2639 // -----------------------------------------------------------------------------
2640 void OReportController::alignControlsWithUndo(USHORT _nUndoStrId,sal_Int32 _nControlModification,bool _bAlignAtSection)
2642 const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2643 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
2644 m_pMyOwnView->alignMarkedObjects(_nControlModification,_bAlignAtSection);
2645 InvalidateFeature( SID_SAVEDOC );
2646 InvalidateFeature( SID_UNDO );
2648 // -----------------------------------------------------------------------------
2649 void OReportController::shrinkSectionBottom(uno::Reference<report::XSection> _xSection)
2651 const sal_Int32 nElements = _xSection->getCount();
2652 if (nElements == 0)
2654 // there are no elements
2655 return;
2657 const sal_Int32 nSectionHeight = _xSection->getHeight();
2658 // sal_Int32 nMinPositionY = nSectionHeight;
2659 sal_Int32 nMaxPositionY = 0;
2660 uno::Reference< report::XReportComponent> xReportComponent;
2662 // for every component get it's Y-position and compare it to the current Y-position
2663 for (int i=0;i<nElements;i++)
2665 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2666 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2667 const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2668 const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2669 // nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2670 nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2672 // now we know the minimal Y-Position and maximal Y-Position
2674 if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning
2676 // the lowest position is already 0
2677 return;
2679 _xSection->setHeight(nMaxPositionY);
2682 void OReportController::shrinkSectionTop(uno::Reference<report::XSection> _xSection)
2684 const sal_Int32 nElements = _xSection->getCount();
2685 if (nElements == 0)
2687 // there are no elements
2688 return;
2691 const sal_Int32 nSectionHeight = _xSection->getHeight();
2692 sal_Int32 nMinPositionY = nSectionHeight;
2693 // sal_Int32 nMaxPositionY = 0;
2694 uno::Reference< report::XReportComponent> xReportComponent;
2696 // for every component get it's Y-position and compare it to the current Y-position
2697 for (int i=0;i<nElements;i++)
2699 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2700 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2701 // const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2702 // const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2703 nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2704 // nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2706 // now we know the minimal Y-Position and maximal Y-Position
2707 if (nMinPositionY == 0)
2709 // the lowest position is already 0
2710 return;
2712 for (int i=0;i<nElements;i++)
2714 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2715 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2716 const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY;
2717 xReportComponent->setPositionY(nNewPositionY);
2719 const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY;
2720 _xSection->setHeight(nNewSectionHeight);
2723 void OReportController::shrinkSection(USHORT _nUndoStrId, uno::Reference<report::XSection> _xSection, sal_Int32 _nSid)
2725 if ( _xSection.is() )
2727 const String sUndoAction = String((ModuleRes(_nUndoStrId)));
2728 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
2730 if (_nSid == SID_SECTION_SHRINK)
2732 shrinkSectionTop(_xSection);
2733 shrinkSectionBottom(_xSection);
2735 else if (_nSid == SID_SECTION_SHRINK_TOP)
2737 shrinkSectionTop(_xSection);
2739 else if (_nSid == SID_SECTION_SHRINK_BOTTOM)
2741 shrinkSectionBottom(_xSection);
2745 InvalidateFeature( SID_SAVEDOC );
2746 InvalidateFeature( SID_UNDO );
2749 // -----------------------------------------------------------------------------
2750 uno::Any SAL_CALL OReportController::getViewData(void) throw( uno::RuntimeException )
2752 ::osl::MutexGuard aGuard( getMutex() );
2753 typedef ::std::pair< ::rtl::OUString,sal_uInt16> TStringIntPair;
2754 const TStringIntPair pViewDataList[] =
2756 TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GridVisible")), SID_GRID_VISIBLE)
2757 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GridUse")), SID_GRID_USE)
2758 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelplinesMove")), SID_HELPLINES_MOVE)
2759 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowRuler")), SID_RULER)
2760 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlProperties")), SID_SHOW_PROPERTYBROWSER)
2761 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LastPropertyBrowserPage")),SID_PROPERTYBROWSER_LAST_PAGE)
2762 ,TStringIntPair(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SplitPosition")), SID_SPLIT_POSITION)
2765 uno::Sequence<beans::PropertyValue> aCommandProps(sizeof(pViewDataList)/sizeof(pViewDataList[0]));
2766 beans::PropertyValue* pIter = aCommandProps.getArray();
2767 beans::PropertyValue* pEnd = pIter + aCommandProps.getLength();
2768 for (sal_Int32 i = 0; pIter != pEnd; ++pIter,++i)
2770 FeatureState aFeatureState = GetState(pViewDataList[i].second);
2771 pIter->Name = pViewDataList[i].first;
2772 if ( !!aFeatureState.bChecked )
2773 pIter->Value <<= (*aFeatureState.bChecked) ? sal_True : sal_False;
2774 else if ( aFeatureState.aValue.hasValue() )
2775 pIter->Value = aFeatureState.aValue;
2777 } // for (; pIter != pEnd; ++pIter)
2779 uno::Sequence<beans::PropertyValue> aProps(1);
2780 aProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CommandProperties"));
2781 aProps[0].Value <<= aCommandProps;
2783 if ( m_pMyOwnView )
2785 ::std::vector<sal_uInt16> aCollapsedPositions;
2786 m_pMyOwnView->fillCollapsedSections(aCollapsedPositions);
2787 if ( !aCollapsedPositions.empty() )
2789 uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
2790 beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
2791 ::std::vector<sal_uInt16>::iterator aIter = aCollapsedPositions.begin();
2792 ::std::vector<sal_uInt16>::iterator aEnd = aCollapsedPositions.end();
2793 for (sal_Int32 i = 1; aIter != aEnd ; ++aIter,++pCollapsedIter,++i)
2795 pCollapsedIter->Name = PROPERTY_SECTION + ::rtl::OUString::valueOf(i);
2796 pCollapsedIter->Value <<= static_cast<sal_Int32>(*aIter);
2798 const sal_Int32 nCount = aProps.getLength();
2799 aProps.realloc( nCount + 1 );
2800 aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CollapsedSections"));
2801 aProps[nCount].Value <<= aCollapsedSections;
2804 ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_pMyOwnView->getMarkedSection();
2805 if ( pSectionWindow.get() )
2807 const sal_Int32 nCount = aProps.getLength();
2808 aProps.realloc( nCount + 1 );
2809 aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MarkedSection"));
2810 aProps[nCount].Value <<= (sal_Int32)pSectionWindow->getReportSection().getPage()->GetPageNum();
2811 } // if ( pSectionWindow.get() )
2812 } // if ( m_pMyOwnView )
2813 const sal_Int32 nCount = aProps.getLength();
2814 aProps.realloc( nCount + 1 );
2815 aProps[nCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ZoomFactor"));
2816 aProps[nCount].Value <<= m_nZoomValue;
2817 return uno::makeAny(aProps);
2819 // -----------------------------------------------------------------------------
2820 void SAL_CALL OReportController::restoreViewData(const uno::Any& Data) throw( uno::RuntimeException )
2822 ::osl::MutexGuard aGuard( getMutex() );
2823 uno::Sequence<beans::PropertyValue> aProps;
2824 if ( Data >>= aProps )
2826 const beans::PropertyValue* pPropsIter = aProps.getConstArray();
2827 const beans::PropertyValue* pPropsEnd = pPropsIter + aProps.getLength();
2828 for (sal_Int32 i = 0; pPropsIter != pPropsEnd; ++pPropsIter,++i)
2830 if ( pPropsIter->Name.equalsAscii("CommandProperties") )
2832 util::URL aCommand;
2833 uno::Sequence< beans::PropertyValue> aArgs(1);
2834 beans::PropertyValue* pArg = aArgs.getArray();
2835 pArg->Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
2836 uno::Sequence< beans::PropertyValue> aCommandProps;
2837 if ( pPropsIter->Value >>= aCommandProps )
2839 const beans::PropertyValue* pIter = aCommandProps.getConstArray();
2840 const beans::PropertyValue* pEnd = pIter + aCommandProps.getLength();
2841 for (; pIter != pEnd; ++pIter)
2843 pArg->Value = pIter->Value;
2844 if ( pArg->Value.hasValue() )
2846 aCommand.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:")) + pIter->Name;
2847 executeUnChecked(aCommand,aArgs);
2852 else if ( pPropsIter->Name.equalsAscii("CollapsedSections") )
2853 pPropsIter->Value >>= m_aCollapsedSections;
2854 else if ( pPropsIter->Name.equalsAscii("MarkedSection") )
2855 pPropsIter->Value >>= m_nPageNum;
2856 else if ( pPropsIter->Name.equalsAscii("ZoomFactor") )
2857 pPropsIter->Value >>= m_nZoomValue;
2861 // -----------------------------------------------------------------------------
2862 void OReportController::updateFloater()
2864 if ( m_pGroupsFloater && m_pGroupsFloater->IsVisible() )
2865 m_pGroupsFloater->UpdateData();
2868 // -----------------------------------------------------------------------------
2869 Reference<XFrame> OReportController::getXFrame()
2871 if ( !m_xFrameLoader.is() )
2873 m_xFrameLoader.set(getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))),uno::UNO_QUERY_THROW);
2875 const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
2876 const ::rtl::OUString sTarget(RTL_CONSTASCII_USTRINGPARAM("_blank"));
2877 Reference<XFrame> xFrame = Reference<XFrame>(m_xFrameLoader,uno::UNO_QUERY_THROW)->findFrame(sTarget,nFrameSearchFlag);
2878 return xFrame;
2881 // -----------------------------------------------------------------------------
2882 uno::Reference<frame::XModel> OReportController::executeReport()
2884 OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?");
2886 uno::Reference<frame::XModel> xModel;
2887 if ( m_xReportDefinition.is() )
2889 sal_uInt16 nErrorId = RID_ERR_NO_COMMAND;
2890 bool bEnabled = m_xReportDefinition->getCommand().getLength() != 0;
2891 if ( bEnabled )
2893 bEnabled = false;
2894 const sal_uInt16 nCount = m_aReportModel->GetPageCount();
2895 sal_uInt16 i = 0;
2896 for (; i < nCount && !bEnabled ; ++i)
2898 const SdrPage* pPage = m_aReportModel->GetPage(i);
2899 bEnabled = pPage->GetObjCount() != 0;
2901 if ( !bEnabled )
2902 nErrorId = RID_ERR_NO_OBJECTS;
2905 dbtools::SQLExceptionInfo aInfo;
2906 if ( !bEnabled )
2908 sdb::SQLContext aFirstMessage;
2909 String sInfo = String( ModuleRes( nErrorId ) );
2910 aFirstMessage.Message = sInfo;
2911 aInfo = aFirstMessage;
2912 if ( isEditable() )
2914 sal_uInt16 nCommand = 0;
2915 if ( nErrorId == RID_ERR_NO_COMMAND )
2917 if ( !m_bShowProperties )
2918 executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>());
2920 m_sLastActivePage = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data"));
2921 m_pMyOwnView->setCurrentPage(m_sLastActivePage);
2922 nCommand = SID_SELECT_REPORT;
2924 else if ( m_pMyOwnView && !m_pMyOwnView->isAddFieldVisible() )
2926 nCommand = SID_FM_ADD_FIELD;
2928 if ( nCommand )
2930 uno::Sequence< beans::PropertyValue> aArgs;
2931 executeUnChecked(nCommand,aArgs);
2935 else
2937 m_bInGeneratePreview = true;
2940 WaitObject aWait(getView()); // cursor
2941 if ( !m_xReportEngine.is() )
2942 m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW);
2943 m_xReportEngine->setReportDefinition(m_xReportDefinition);
2944 m_xReportEngine->setActiveConnection(getConnection());
2945 Reference<XFrame> xFrame = getXFrame();
2946 xModel = m_xReportEngine->createDocumentAlive(xFrame);
2948 catch( const sdbc::SQLException& /*e*/ )
2949 { // SQLExceptions and derived exceptions must not be translated
2950 aInfo = ::cppu::getCaughtException();
2952 catch(const uno::Exception& e)
2954 uno::Any aCaughtException( ::cppu::getCaughtException() );
2956 // our first message says: we caught an exception
2957 sdb::SQLContext aFirstMessage;
2958 String sInfo = String( ModuleRes( RID_STR_CAUGHT_FOREIGN_EXCEPTION ) );
2959 sInfo.SearchAndReplaceAllAscii( "$type$", aCaughtException.getValueTypeName() );
2960 aFirstMessage.Message = sInfo;
2962 // our second message: the message of the exception we caught
2963 sdbc::SQLException aSecondMessage;
2964 aSecondMessage.Message = e.Message;
2965 aSecondMessage.Context = e.Context;
2967 // maybe our third message: the message which is wrapped in the exception we caught
2968 sdbc::SQLException aThirdMessage;
2969 lang::WrappedTargetException aWrapped;
2970 if ( aCaughtException >>= aWrapped )
2972 aThirdMessage.Message = aWrapped.Message;
2973 aThirdMessage.Context = aWrapped.Context;
2976 if ( aThirdMessage.Message.getLength() )
2977 aSecondMessage.NextException <<= aThirdMessage;
2978 aFirstMessage.NextException <<= aSecondMessage;
2980 aInfo = aFirstMessage;
2982 if (aInfo.isValid())
2984 const String suSQLContext = String( ModuleRes( RID_STR_COULD_NOT_CREATE_REPORT ) );
2985 aInfo.prepend(suSQLContext);
2986 } // if (aInfo.isValid())
2987 m_bInGeneratePreview = false;
2990 if (aInfo.isValid())
2992 showError(aInfo);
2995 return xModel;
2997 // -----------------------------------------------------------------------------
2998 uno::Reference< frame::XModel > SAL_CALL OReportController::getModel(void) throw( uno::RuntimeException )
3000 return m_xReportDefinition.get();
3002 // -----------------------------------------------------------------------------
3003 uno::Reference< sdbc::XRowSet > OReportController::getRowSet()
3005 OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" );
3007 if ( m_xRowSet.is() || !m_xReportDefinition.is() )
3008 return m_xRowSet;
3012 uno::Reference< sdbc::XRowSet > xRowSet( getORB()->createInstance(
3013 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.RowSet" ) ) ), uno::UNO_QUERY );
3014 uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW );
3016 xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) );
3017 xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( sal_True ) );
3019 ::boost::shared_ptr<AnyConverter> aNoConverter(new AnyConverter());
3020 TPropertyNamePair aPropertyMediation;
3021 aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) ) );
3022 aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) ) );
3023 aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) ) );
3024 aPropertyMediation.insert( TPropertyNamePair::value_type( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) ) );
3026 m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation );
3027 m_xRowSet = xRowSet;
3029 catch( const uno::Exception& )
3031 DBG_UNHANDLED_EXCEPTION();
3034 return m_xRowSet;
3036 // -----------------------------------------------------------------------------
3037 void OReportController::insertGraphic()
3039 const String sTitle(ModuleRes(RID_STR_IMPORT_GRAPHIC));
3040 // build some arguments for the upcoming dialog
3043 uno::Reference< report::XSection> xSection = m_pMyOwnView->getCurrentSection();
3044 ::sfx2::FileDialogHelper aDialog( ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, SFXWB_GRAPHIC );
3045 aDialog.SetTitle( sTitle );
3047 uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
3048 xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));
3049 xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, sal_False/*sal_True*/);
3050 sal_Bool bLink = sal_True;
3051 xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any( bLink ) );
3053 if ( ERRCODE_NONE == aDialog.Execute() )
3055 xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink;
3056 uno::Sequence<beans::PropertyValue> aArgs(2);
3057 aArgs[0].Name = PROPERTY_IMAGEURL;
3058 aArgs[0].Value <<= ::rtl::OUString(aDialog.GetPath());
3059 aArgs[1].Name = PROPERTY_PRESERVEIRI;
3060 aArgs[1].Value <<= bLink;
3061 createControl(aArgs,xSection,::rtl::OUString(),OBJ_DLG_IMAGECONTROL);
3064 catch(Exception&)
3066 DBG_UNHANDLED_EXCEPTION();
3069 // -----------------------------------------------------------------------------
3070 ::boost::shared_ptr<rptui::OReportModel> OReportController::getSdrModel()
3072 if ( !m_aReportModel )
3074 m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
3075 if ( m_aReportModel )
3077 m_aReportModel->attachController( *this );
3078 m_aReportModel->SetNotifyUndoActionHdl(LINK( this, OReportController, NotifyUndoActionHdl ));
3081 return m_aReportModel;
3083 // -----------------------------------------------------------------------------
3084 ::sal_Bool SAL_CALL OReportController::select( const Any& aSelection ) throw (IllegalArgumentException, RuntimeException)
3086 ::osl::MutexGuard aGuard( getMutex() );
3087 ::sal_Bool bRet = sal_True;
3088 if ( m_pMyOwnView )
3090 m_pMyOwnView->unmarkAllObjects(NULL);
3091 m_pMyOwnView->SetMode(RPTUI_SELECT);
3093 uno::Sequence< uno::Reference<report::XReportComponent> > aElements;
3094 if ( aSelection >>= aElements )
3096 if ( aElements.getLength() > 0 )
3097 m_pMyOwnView->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY));
3098 m_pMyOwnView->setMarked(aElements,sal_True);
3100 else
3102 uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY);
3103 uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY);
3104 if ( xProp.is() )
3106 m_pMyOwnView->showProperties(xObject);
3107 aElements.realloc(1);
3108 aElements[0] = xProp;
3109 m_pMyOwnView->setMarked(aElements,sal_True);
3111 else
3113 uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY);
3114 if ( !xSection.is() && xObject.is() )
3115 m_pMyOwnView->showProperties(xObject);
3116 m_pMyOwnView->setMarked(xSection,xSection.is());
3119 InvalidateAll();
3121 return bRet;
3123 // -----------------------------------------------------------------------------
3124 Any SAL_CALL OReportController::getSelection( ) throw (RuntimeException)
3126 ::osl::MutexGuard aGuard( getMutex() );
3127 Any aRet;
3128 if ( m_pMyOwnView )
3130 aRet = m_pMyOwnView->getCurrentlyShownProperty();
3131 if ( !aRet.hasValue() )
3132 aRet <<= m_pMyOwnView->getCurrentSection();
3134 return aRet;
3136 // -----------------------------------------------------------------------------
3137 void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
3139 m_aSelectionListeners.addInterface( _Listener );
3141 // -----------------------------------------------------------------------------
3142 void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException)
3144 m_aSelectionListeners.removeInterface( _Listener );
3146 // -----------------------------------------------------------------------------
3147 void OReportController::createNewFunction(const uno::Any& _aValue)
3149 uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW);
3150 const ::rtl::OUString sNewName = String(ModuleRes(RID_STR_FUNCTION));
3151 uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext));
3152 xFunction->setName(sNewName);
3153 // the call below will also create an undo action -> listener
3154 xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction));
3156 // -----------------------------------------------------------------------------
3157 IMPL_LINK( OReportController, OnExecuteReport, void* ,/*_pMemfun*/)
3159 //m_nExecuteReportEvent = 0;
3160 executeReport();
3161 return 0L;
3163 // -----------------------------------------------------------------------------
3164 void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const ::rtl::OUString& _sFunction,sal_uInt16 _nObjectId)
3166 SequenceAsHashMap aMap(_aArgs);
3167 m_pMyOwnView->setMarked(_xSection ,sal_True);
3168 ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_pMyOwnView->getMarkedSection();
3169 if ( !pSectionWindow )
3170 return;
3172 OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the corrct one.");
3174 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3175 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3176 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3177 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3178 if ( aPos.X < nLeftMargin )
3179 aPos.X = nLeftMargin;
3181 SdrObject* pNewControl = NULL;
3182 uno::Reference< report::XReportComponent> xShapeProp;
3183 if ( _nObjectId == OBJ_CUSTOMSHAPE )
3185 pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
3186 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY);
3187 ::rtl::OUString sCustomShapeType = m_pMyOwnView->GetInsertObjString();
3188 if ( !sCustomShapeType.getLength() )
3189 sCustomShapeType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diamond"));
3190 pSectionWindow->getReportSection().createDefault(sCustomShapeType,pNewControl);
3191 pNewControl->SetLogicRect(Rectangle(3000,500,6000,3500)); // switch height and width
3192 } // if ( _nObjectId == OBJ_CUSTOMSHAPE )
3193 else if ( _nObjectId == OBJ_OLE2 || OBJ_DLG_SUBREPORT == _nObjectId )
3195 pNewControl = SdrObjFactory::MakeNewObject( ReportInventor, _nObjectId, pSectionWindow->getReportSection().getPage(),m_aReportModel.get() );
3197 pNewControl->SetLogicRect(Rectangle(3000,500,8000,5500)); // switch height and width
3198 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
3199 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
3200 if ( pObj && !pObj->IsEmpty() )
3202 pObj->initializeChart(getModel());
3205 else
3207 SdrUnoObj* pLabel( NULL );
3208 SdrUnoObj* pControl( NULL );
3209 FmFormView::createControlLabelPair(m_pMyOwnView
3210 ,nLeftMargin,0
3211 ,NULL,NULL,_nObjectId,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
3212 NULL,pSectionWindow->getReportSection().getPage(),m_aReportModel.get(),
3213 pLabel,pControl);
3214 delete pLabel;
3216 pNewControl = pControl;
3217 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl);
3218 uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
3219 xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
3220 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3221 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3223 const ::rtl::OUString sProps[] = { PROPERTY_NAME
3224 ,PROPERTY_FONTDESCRIPTOR
3225 ,PROPERTY_FONTDESCRIPTORASIAN
3226 ,PROPERTY_FONTDESCRIPTORCOMPLEX
3227 ,PROPERTY_ORIENTATION
3228 ,PROPERTY_BORDER
3229 ,PROPERTY_FORMATSSUPPLIER
3230 ,PROPERTY_BACKGROUNDCOLOR
3232 for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i)
3234 if ( xInfo->hasPropertyByName(sProps[i]) && xShapeInfo->hasPropertyByName(sProps[i]) )
3235 xUnoProp->setPropertyValue(sProps[i],xShapeProp->getPropertyValue(sProps[i]));
3236 } // for(size_t i = 0; i < sizeof(sProps)/sizeof(sProps[0]);++i)
3238 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3239 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3242 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && _sFunction.getLength() )
3244 ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
3245 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
3248 sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
3249 if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
3250 xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
3252 ::rtl::OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,::rtl::OUString());
3253 if ( sUrl.getLength() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
3254 xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
3256 pObj->CreateMediator(sal_True);
3258 if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
3259 xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
3260 else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
3262 awt::Size aOlSize = xShapeProp->getSize();
3263 xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
3267 const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
3268 if ( nShapeWidth != xShapeProp->getWidth() )
3269 xShapeProp->setWidth( nShapeWidth );
3271 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3272 if ( bChangedPos )
3273 aPos.X = nPaperWidth - nShapeWidth;
3274 xShapeProp->setPosition(aPos);
3276 correctOverlapping(pNewControl,pSectionWindow->getReportSection());
3278 // -----------------------------------------------------------------------------
3279 void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
3281 m_pMyOwnView->unmarkAllObjects(NULL);
3283 const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
3284 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
3286 SequenceAsHashMap aMap(_aArgs);
3287 aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0)));
3289 uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>());
3290 ::rtl::OUString sFunction;
3292 sal_Bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE,sal_False);
3293 if ( bDate )
3295 sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TODAY()"));
3296 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3298 sal_Bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE,sal_False);
3299 if ( bTime )
3301 sFunction = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("TIMEVALUE(NOW())"));
3302 aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0));
3303 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3306 // -----------------------------------------------------------------------------
3307 void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs)
3309 m_pMyOwnView->unmarkAllObjects(NULL);
3311 const String sUndoAction(ModuleRes(RID_STR_UNDO_INSERT_CONTROL));
3312 UndoManagerListAction aListAction(m_aUndoManager,sUndoAction);
3314 if ( !m_xReportDefinition->getPageHeaderOn() )
3316 uno::Sequence< beans::PropertyValue > aArgs;
3317 executeChecked(SID_PAGEHEADERFOOTER,aArgs);
3318 } // if ( !m_xHoldAlive->getPageHeaderOn() )
3320 SequenceAsHashMap aMap(_aArgs);
3321 sal_Bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE,sal_False);
3323 String sFunction = String(ModuleRes(STR_RPT_PN_PAGE));
3324 ::rtl::OUString sPageNumber(RTL_CONSTASCII_USTRINGPARAM("PageNumber()"));
3325 sFunction.SearchAndReplace(String::CreateFromAscii("#PAGENUMBER#"),sPageNumber);
3327 if ( bStateOfPage )
3329 ::rtl::OUString sPageCount(RTL_CONSTASCII_USTRINGPARAM("PageCount()"));
3330 sFunction += String(ModuleRes(STR_RPT_PN_PAGE_OF));
3331 sFunction.SearchAndReplace(String::CreateFromAscii("#PAGECOUNT#"),sPageCount);
3334 sal_Bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON,sal_True);
3335 createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction);
3338 // -----------------------------------------------------------------------------
3339 void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
3341 m_pMyOwnView->unmarkAllObjects(NULL);
3342 //////////////////////////////////////////////////////////////////////
3343 // Anhand des FormatKeys wird festgestellt, welches Feld benoetigt wird
3344 ::boost::shared_ptr<OSectionWindow> pSectionWindow[2];
3345 pSectionWindow[0] = m_pMyOwnView->getMarkedSection();
3347 if ( !pSectionWindow[0] )
3349 select(uno::makeAny(m_xReportDefinition->getDetail()));
3350 pSectionWindow[0] = m_pMyOwnView->getMarkedSection();
3351 if ( !pSectionWindow[0] )
3352 return;
3355 uno::Reference<report::XSection> xCurrentSection = m_pMyOwnView->getCurrentSection();
3356 UndoManagerListAction aUndo( *getUndoMgr(), String( ModuleRes( RID_STR_UNDO_INSERT_CONTROL ) ) );
3360 bool bHandleOnlyOne = false;
3361 const PropertyValue* pIter = aArgs.getConstArray();
3362 const PropertyValue* pEnd = pIter + aArgs.getLength();
3363 for(;pIter != pEnd && !bHandleOnlyOne;++pIter)
3365 Sequence< PropertyValue > aValue;
3366 if ( !(pIter->Value >>= aValue) )
3367 { // the sequence has only one element which already contains the descriptor
3368 bHandleOnlyOne = true;
3369 aValue = aArgs;
3371 ::svx::ODataAccessDescriptor aDescriptor(aValue);
3372 SequenceAsHashMap aMap(aValue);
3373 uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Section")),xCurrentSection);
3374 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
3376 m_pMyOwnView->setMarked(xSection,sal_True);
3377 pSectionWindow[0] = m_pMyOwnView->getMarkedSection();
3379 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3380 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3381 if ( aPos.X < nLeftMargin )
3382 aPos.X = nLeftMargin;
3384 // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down
3385 sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DNDAction")), sal_Int8(0));
3386 pSectionWindow[1] = pSectionWindow[0];
3387 // ::boost::shared_ptr<OReportSection> pReportSectionPost;
3388 sal_Bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY;
3389 if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK )
3391 // Add the Label one Section up
3392 pSectionWindow[1] = m_pMyOwnView->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST);
3393 if (!pSectionWindow[1])
3395 // maybe out of bounds
3396 pSectionWindow[1] = pSectionWindow[0];
3399 // clear all selections
3400 m_pMyOwnView->unmarkAllObjects(NULL);
3402 uno::Reference< beans::XPropertySet > xField( aDescriptor[ ::svx::daColumnObject ], uno::UNO_QUERY );
3403 uno::Reference< lang::XComponent > xHoldAlive;
3404 if ( !xField.is() )
3406 ::rtl::OUString sCommand;
3407 ::rtl::OUString sColumnName;
3408 sal_Int32 nCommandType( -1 );
3409 OSL_VERIFY( aDescriptor[ ::svx::daCommand ] >>= sCommand );
3410 OSL_VERIFY( aDescriptor[ ::svx::daColumnName ] >>= sColumnName );
3411 OSL_VERIFY( aDescriptor[ ::svx::daCommandType ] >>= nCommandType );
3413 uno::Reference< container::XNameAccess > xColumns;
3414 uno::Reference< sdbc::XConnection > xConnection( getConnection() );
3415 if ( sCommand.getLength() && nCommandType != -1 && sColumnName.getLength() && xConnection.is() )
3417 if ( !xReportDefinition->getCommand().getLength() )
3419 xReportDefinition->setCommand(sCommand);
3420 xReportDefinition->setCommandType(nCommandType);
3421 } // if ( !xReportDefinition->getCommand().getLength() )
3423 xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive);
3424 if ( xColumns.is() && xColumns->hasByName(sColumnName) )
3425 xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY );
3428 if ( !xField.is() )
3430 #if OSL_DEBUG_LEVEL > 0
3433 uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
3434 ::rtl::OUString sRowSetCommand;
3435 sal_Int32 nRowSetCommandType( -1 );
3436 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand );
3437 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType );
3438 OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ),
3439 "OReportController::addPairControls: this only works for a data source which equals our current settings!" );
3440 // if this asserts, then either our row set and our report definition are not in sync, or somebody
3441 // requested the creation of a control/pair for another data source than what our report
3442 // definition is bound to - which is not supported for the parameters case, since we
3443 // can retrieve parameters from the RowSet only.
3445 catch( const Exception& )
3447 DBG_UNHANDLED_EXCEPTION();
3449 #endif
3451 // no column name - perhaps a parameter name?
3452 uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW );
3453 uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_QUERY_THROW );
3454 sal_Int32 nParamCount( xParams->getCount() );
3455 for ( sal_Int32 i=0; i<nParamCount; ++i)
3457 uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
3458 ::rtl::OUString sParamName;
3459 OSL_VERIFY( xParamCol->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sParamName );
3460 if ( sParamName == sColumnName )
3462 xField = xParamCol;
3463 break;
3468 if ( !xField.is() )
3469 continue;
3471 sal_uInt16 nOBJID = 0;
3472 sal_Int32 nDataType = sdbc::DataType::BINARY;
3473 xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
3474 switch ( nDataType )
3476 case sdbc::DataType::BINARY:
3477 case sdbc::DataType::VARBINARY:
3478 case sdbc::DataType::LONGVARBINARY:
3479 nOBJID = OBJ_DLG_IMAGECONTROL;
3480 break;
3481 default:
3482 nOBJID = OBJ_DLG_FORMATTEDFIELD;
3483 break;
3486 if ( !nOBJID )
3487 continue;
3489 Reference< util::XNumberFormatsSupplier > xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier();
3490 if ( !xSupplier.is() )
3491 continue;
3493 Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats());
3494 SdrUnoObj* pControl[2];
3495 pControl[0] = NULL;
3496 pControl[1] = NULL;
3497 //m_pMyOwnView->GetModel()->GetUndoEnv().Lock();
3498 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3499 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3500 OSectionView* pSectionViews[2];
3501 pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView();
3502 pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView();
3503 // find this in svx
3504 FmFormView::createControlLabelPair(m_pMyOwnView
3505 ,nLeftMargin,0
3506 ,xField,xNumberFormats,nOBJID,::rtl::OUString(),ReportInventor,OBJ_DLG_FIXEDTEXT,
3507 pSectionWindow[1]->getReportSection().getPage(),pSectionWindow[0]->getReportSection().getPage(),m_aReportModel.get(),
3508 pControl[0],pControl[1]);
3509 //m_pMyOwnView->GetModel()->GetUndoEnv().UnLock();
3510 if ( pControl[0] && pControl[1] )
3512 SdrPageView* pPgViews[2];
3513 pPgViews[0] = pSectionViews[0]->GetSdrPageView();
3514 pPgViews[1] = pSectionViews[1]->GetSdrPageView();
3515 if ( pPgViews[0] && pPgViews[1] )
3517 ::rtl::OUString sDefaultName;
3518 size_t i = 0;
3519 OUnoObject* pObjs[2];
3520 for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
3522 pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i]);
3523 uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
3524 uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
3525 xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
3527 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3528 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3529 const ::rtl::OUString sProps[] = { PROPERTY_FONTDESCRIPTOR
3530 ,PROPERTY_FONTDESCRIPTORASIAN
3531 ,PROPERTY_FONTDESCRIPTORCOMPLEX
3532 ,PROPERTY_BORDER
3533 ,PROPERTY_BACKGROUNDCOLOR
3535 for(size_t k = 0; k < sizeof(sProps)/sizeof(sProps[0]);++k)
3537 if ( xInfo->hasPropertyByName(sProps[k]) && xShapeInfo->hasPropertyByName(sProps[k]) )
3538 xUnoProp->setPropertyValue(sProps[k],xShapeProp->getPropertyValue(sProps[k]));
3540 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3542 ::rtl::OUString sName;
3543 xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName;
3544 sDefaultName = sName;
3545 xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName));
3547 ReportFormula aFormula( ReportFormula::Field, sName );
3548 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) );
3549 } // if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3551 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3552 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3554 pObjs[i]->CreateMediator(sal_True);
3555 // need SectionView from the above or follow Section
3556 // (getMarkedSection) returns the current Section
3557 //pSectionViews[i]->InsertObjectAtView(pControl[i],*pPgViews[i],SDRINSERT_ADDMARK);
3559 const sal_Int32 nShapeWidth = xShapeProp->getWidth();
3560 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3561 if ( bChangedPos )
3562 aPos.X = nPaperWidth - nShapeWidth;
3563 xShapeProp->setPosition(aPos);
3564 if ( bChangedPos )
3565 aPos.Y += xShapeProp->getHeight();
3566 aPos.X += nShapeWidth;
3568 if (pSectionViews[0] != pSectionViews[1] &&
3569 nOBJID == OBJ_DLG_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD
3571 // we have two different Views, so set the position x new.
3572 // pSectionViews[1].position.x = pSectionViews[0].position.x
3573 uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3574 uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3575 awt::Point aPosLabel = xShapePropLabel->getPosition();
3576 awt::Point aPosTextField = xShapePropTextField->getPosition();
3577 aPosTextField.X = aPosLabel.X;
3578 xShapePropTextField->setPosition(aPosTextField);
3579 if (bLabelAboveTextField)
3581 // move the label down near the splitter
3582 const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection();
3583 aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight();
3585 else
3587 // move the label up to the splitter
3588 aPosLabel.Y = 0;
3590 xShapePropLabel->setPosition(aPosLabel);
3592 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0]);
3593 uno::Reference< report::XReportComponent> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
3594 xShapeProp->setName(xShapeProp->getName() + sDefaultName );
3596 for(i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i) // insert controls
3598 correctOverlapping(pControl[i],pSectionWindow[1-i]->getReportSection());
3601 if (!bLabelAboveTextField )
3603 if ( pSectionViews[0] == pSectionViews[1] )
3605 Rectangle aLabel = getRectangleFromControl(pControl[0]);
3606 Rectangle aTextfield = getRectangleFromControl(pControl[1]);
3608 // create a Union of the given Label and Textfield
3609 Rectangle aLabelAndTextfield( aLabel );
3610 aLabelAndTextfield.Union(aTextfield);
3612 // check if there exists other fields and if yes, move down
3613 bool bOverlapping = true;
3614 bool bHasToMove = false;
3615 while ( bOverlapping )
3617 const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2);
3618 bOverlapping = pOverlappedObj != NULL;
3619 if ( bOverlapping )
3621 const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
3622 aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top());
3623 bHasToMove = true;
3627 if (bHasToMove)
3629 // There was a move down, we need to move the Label and the Textfield down
3630 aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top());
3631 aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
3633 uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3634 xLabel->setPositionY(aLabel.Top());
3636 uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3637 xTextfield->setPositionY(aTextfield.Top());
3640 // this should never happen.
3641 // else
3642 // {
3643 // DBG_ERROR("unhandled case.");
3644 // }
3648 else
3650 for(size_t i = 0; i < sizeof(pControl)/sizeof(pControl[0]);++i)
3651 delete pControl[i];
3655 catch( const Exception& )
3657 DBG_UNHANDLED_EXCEPTION();
3661 // -----------------------------------------------------------------------------
3662 OSectionView* OReportController::getCurrentSectionView() const
3664 OSectionView* pSectionView = NULL;
3665 ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_pMyOwnView->getMarkedSection();
3666 if ( pSectionWindow.get() )
3667 pSectionView = &pSectionWindow->getReportSection().getSectionView();
3668 return pSectionView;
3670 // -----------------------------------------------------------------------------
3671 void OReportController::changeZOrder(sal_Int32 _nId)
3673 OSectionView* pSectionView = getCurrentSectionView();
3674 if ( pSectionView )
3676 switch(_nId)
3678 case SID_FRAME_TO_BOTTOM:
3679 pSectionView->PutMarkedToBtm();
3680 break;
3681 case SID_FRAME_TO_TOP:
3682 pSectionView->PutMarkedToTop();
3683 break;
3684 case SID_FRAME_DOWN:
3685 pSectionView->MovMarkedToBtm();
3686 break;
3687 case SID_FRAME_UP:
3688 pSectionView->MovMarkedToTop();
3689 break;
3691 case SID_OBJECT_HEAVEN:
3692 pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT );
3693 break;
3694 case SID_OBJECT_HELL:
3695 pSectionView->SetMarkedToLayer( RPT_LAYER_BACK );
3696 break;
3700 // -----------------------------------------------------------------------------
3701 void OReportController::listen(const bool _bAdd)
3703 const ::rtl::OUString aProps [] = { PROPERTY_REPORTHEADERON,PROPERTY_REPORTFOOTERON
3704 ,PROPERTY_PAGEHEADERON,PROPERTY_PAGEFOOTERON
3705 ,PROPERTY_COMMAND, PROPERTY_COMMANDTYPE,PROPERTY_CAPTION
3708 void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const ::rtl::OUString&, const uno::Reference< XPropertyChangeListener >& ) =
3709 _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
3711 for (size_t i = 0; i < sizeof(aProps)/sizeof(aProps[0]); ++i)
3712 (m_xReportDefinition.get()->*pPropertyListenerAction)( aProps[i], static_cast< XPropertyChangeListener* >( this ) );
3714 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3715 uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
3716 uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
3717 const beans::Property* pIter = aSeq.getConstArray();
3718 const beans::Property* pEnd = pIter + aSeq.getLength();
3719 const ::rtl::OUString* pPropsBegin = &aProps[0];
3720 const ::rtl::OUString* pPropsEnd = pPropsBegin + (sizeof(aProps)/sizeof(aProps[0])) - 3;
3721 for(;pIter != pEnd;++pIter)
3723 if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd )
3724 (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo );
3727 // Add Listeners to UndoEnvironment
3728 void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) =
3729 _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement;
3731 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() );
3732 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() );
3734 // Add Listeners to ReportControllerObserver
3735 OXReportControllerObserver& rObserver = *m_pReportControllerObserver;
3736 // void (OXReportControllerObserver::*pObserverFunction)( const uno::Reference< uno::XInterface >& ) =
3737 // _bAdd ? &OXReportControllerObserver::AddElement : &OXReportControllerObserver::RemoveElement;
3739 // (rObserver.*pObserverFunction)( m_xReportDefinition->getStyleFamilies() );
3740 // (rObserver.*pObserverFunction)( m_xReportDefinition->getFunctions() );
3742 if ( m_xReportDefinition->getPageHeaderOn() && _bAdd )
3744 m_pMyOwnView->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER);
3745 rObserver.AddSection(m_xReportDefinition->getPageHeader());
3747 if ( m_xReportDefinition->getReportHeaderOn() && _bAdd )
3749 m_pMyOwnView->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER);
3750 rObserver.AddSection(m_xReportDefinition->getReportHeader());
3753 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3754 const sal_Int32 nCount = xGroups->getCount();
3755 _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv);
3756 _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver);
3758 for (sal_Int32 i=0;i<nCount ; ++i)
3760 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
3761 (xGroup.get()->*pPropertyListenerAction)( PROPERTY_HEADERON, static_cast< XPropertyChangeListener* >( this ) );
3762 (xGroup.get()->*pPropertyListenerAction)( PROPERTY_FOOTERON, static_cast< XPropertyChangeListener* >( this ) );
3764 (rUndoEnv.*pElementUndoFunction)( xGroup );
3765 (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() );
3766 if ( xGroup->getHeaderOn() && _bAdd )
3768 m_pMyOwnView->addSection(xGroup->getHeader(),DBGROUPHEADER);
3769 rObserver.AddSection(xGroup->getHeader());
3771 } // for (sal_Int32 i=0;i<nCount ; ++i)
3773 if ( _bAdd )
3775 m_pMyOwnView->addSection(m_xReportDefinition->getDetail(),DBDETAIL);
3776 rObserver.AddSection(m_xReportDefinition->getDetail());
3778 for (sal_Int32 i=nCount;i > 0 ; --i)
3780 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY);
3781 if ( xGroup->getFooterOn() )
3783 m_pMyOwnView->addSection(xGroup->getFooter(),DBGROUPFOOTER);
3784 rObserver.AddSection(xGroup->getFooter());
3787 if ( m_xReportDefinition->getReportFooterOn() )
3789 m_pMyOwnView->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER);
3790 rObserver.AddSection(m_xReportDefinition->getReportFooter());
3792 if ( m_xReportDefinition->getPageFooterOn())
3794 m_pMyOwnView->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
3795 rObserver.AddSection(m_xReportDefinition->getPageFooter());
3798 xGroups->addContainerListener(static_cast<XContainerListener*>(this));
3799 m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this));
3801 else /* ! _bAdd */
3803 rObserver.RemoveSection(m_xReportDefinition->getDetail());
3804 xGroups->removeContainerListener(static_cast<XContainerListener*>(this));
3805 m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this));
3806 m_aReportModel->detachController();
3809 // -----------------------------------------------------------------------------
3810 void OReportController::switchReportSection(const sal_Int16 _nId)
3812 OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!");
3814 if ( m_xReportDefinition.is() )
3816 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3817 const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn();
3818 if ( SID_REPORTHEADERFOOTER == _nId )
3820 const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3821 getUndoMgr()->EnterListAction( sUndoAction, String() );
3823 addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTHEADER_WITHOUT_UNDO
3824 ,::std::mem_fun(&OReportHelper::getReportHeader)
3825 ,m_xReportDefinition
3826 ,bSwitchOn ? Inserted : Removed
3830 addUndoActionAndInvalidate(new OReportSectionUndo(*(m_aReportModel),SID_REPORTFOOTER_WITHOUT_UNDO
3831 ,::std::mem_fun(&OReportHelper::getReportFooter)
3832 ,m_xReportDefinition
3833 ,bSwitchOn ? Inserted : Removed
3838 switch( _nId )
3840 case SID_REPORTHEADER_WITHOUT_UNDO:
3841 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3842 break;
3843 case SID_REPORTFOOTER_WITHOUT_UNDO:
3844 m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() );
3845 break;
3846 case SID_REPORTHEADERFOOTER:
3847 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3848 m_xReportDefinition->setReportFooterOn( bSwitchOn );
3849 break;
3852 if ( SID_REPORTHEADERFOOTER == _nId )
3853 getUndoMgr()->LeaveListAction();
3854 getView()->Resize();
3857 // -----------------------------------------------------------------------------
3858 void OReportController::switchPageSection(const sal_Int16 _nId)
3860 OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!");
3861 if ( m_xReportDefinition.is() )
3863 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3864 const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn();
3866 if ( SID_PAGEHEADERFOOTER == _nId )
3868 const String sUndoAction(ModuleRes(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3869 getUndoMgr()->EnterListAction( sUndoAction, String() );
3871 addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel
3872 ,SID_PAGEHEADER_WITHOUT_UNDO
3873 ,::std::mem_fun(&OReportHelper::getPageHeader)
3874 ,m_xReportDefinition
3875 ,bSwitchOn ? Inserted : Removed
3879 addUndoActionAndInvalidate(new OReportSectionUndo(*m_aReportModel
3880 ,SID_PAGEFOOTER_WITHOUT_UNDO
3881 ,::std::mem_fun(&OReportHelper::getPageFooter)
3882 ,m_xReportDefinition
3883 ,bSwitchOn ? Inserted : Removed
3886 } // if ( SID_PAGEHEADERFOOTER == _nId )
3887 switch( _nId )
3889 case SID_PAGEHEADER_WITHOUT_UNDO:
3890 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3891 break;
3892 case SID_PAGEFOOTER_WITHOUT_UNDO:
3893 m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() );
3894 break;
3895 case SID_PAGEHEADERFOOTER:
3896 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3897 m_xReportDefinition->setPageFooterOn( bSwitchOn );
3898 break;
3900 if ( SID_PAGEHEADERFOOTER == _nId )
3901 getUndoMgr()->LeaveListAction();
3902 getView()->Resize();
3905 // -----------------------------------------------------------------------------
3906 void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs)
3908 if ( !m_xReportDefinition.is() )
3909 return;
3913 const SequenceAsHashMap aMap( _aArgs );
3914 uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() );
3915 if ( !xGroup.is() )
3916 return;
3918 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3919 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3920 if ( _bAppend )
3922 const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() );
3923 xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) );
3924 rUndoEnv.AddElement( xGroup->getFunctions() );
3927 addUndoActionAndInvalidate( new OGroupUndo(
3928 *m_aReportModel,
3929 _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
3930 _bAppend ? Inserted : Removed,
3931 xGroup,
3932 m_xReportDefinition
3933 ) );
3935 if ( !_bAppend )
3937 rUndoEnv.RemoveElement( xGroup->getFunctions() );
3938 const sal_Int32 nPos = getGroupPosition( xGroup );
3939 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3940 xGroups->removeByIndex( nPos );
3943 catch( const Exception& )
3945 DBG_UNHANDLED_EXCEPTION();
3949 // -----------------------------------------------------------------------------
3950 void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs)
3952 if ( m_xReportDefinition.is() )
3954 const SequenceAsHashMap aMap(_aArgs);
3955 const sal_Bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? PROPERTY_HEADERON : PROPERTY_FOOTERON,sal_False);
3956 uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>());
3957 if ( xGroup.is() )
3959 const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
3960 if ( _bUndo )
3961 addUndoActionAndInvalidate(new OGroupSectionUndo(*m_aReportModel
3962 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
3963 ,_bHeader ? ::std::mem_fun(&OGroupHelper::getHeader) : ::std::mem_fun(&OGroupHelper::getFooter)
3964 ,xGroup
3965 ,bSwitchOn ? Inserted : Removed
3966 , ( _bHeader ?
3967 (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER)
3968 :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER)
3972 if ( _bHeader )
3973 xGroup->setHeaderOn( bSwitchOn );
3974 else
3975 xGroup->setFooterOn( bSwitchOn );
3979 // -----------------------------------------------------------------------------
3980 void OReportController::collapseSection(const bool _bCollapse)
3982 ::boost::shared_ptr<OSectionWindow> pSection = m_pMyOwnView->getMarkedSection();
3983 if ( pSection )
3985 pSection->setCollapsed(_bCollapse);
3988 // -----------------------------------------------------------------------------
3989 void OReportController::markSection(const bool _bNext)
3991 ::boost::shared_ptr<OSectionWindow> pSection = m_pMyOwnView->getMarkedSection();
3992 if ( pSection )
3994 ::boost::shared_ptr<OSectionWindow> pPrevSection = m_pMyOwnView->getMarkedSection(_bNext ? POST : PREVIOUS);
3995 if ( pPrevSection != pSection && pPrevSection )
3996 select(uno::makeAny(pPrevSection->getReportSection().getSection()));
3997 else
3998 select(uno::makeAny(m_xReportDefinition));
4000 else
4002 m_pMyOwnView->markSection(_bNext ? 0 : m_pMyOwnView->getSectionCount() - 1);
4003 pSection = m_pMyOwnView->getMarkedSection();
4004 if ( pSection )
4005 select(uno::makeAny(pSection->getReportSection().getSection()));
4008 // -----------------------------------------------------------------------------
4009 void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs)
4011 uno::Reference< report::XSection > xSection = m_pMyOwnView->getCurrentSection();
4012 if ( !xSection.is() )
4013 xSection = m_xReportDefinition->getDetail();
4015 if ( xSection.is() )
4017 const ::rtl::OUString sKeyModifier(RTL_CONSTASCII_USTRINGPARAM("KeyModifier"));
4018 const beans::PropertyValue* pIter = _aArgs.getConstArray();
4019 const beans::PropertyValue* pEnd = pIter + _aArgs.getLength();
4020 const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter,pEnd,::std::bind2nd(PropertyValueCompare(),boost::cref(sKeyModifier)));
4021 sal_Int16 nKeyModifier = 0;
4022 if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) )
4024 Sequence< PropertyValue > aCreateArgs;
4025 m_pMyOwnView->unmarkAllObjects(NULL);
4026 createControl(aCreateArgs,xSection,::rtl::OUString(),m_pMyOwnView->GetInsertObj());
4030 // -----------------------------------------------------------------------------
4031 uno::Reference< util::XNumberFormatter > OReportController::getReportNumberFormatter() const
4033 return m_xFormatter;
4035 // -----------------------------------------------------------------------------
4036 void OReportController::checkChartEnabled()
4038 if ( !m_bChartEnabledAsked )
4040 m_bChartEnabledAsked = true;
4041 const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign" ) );
4042 const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "UserData/Chart" ) );
4046 ::utl::OConfigurationTreeRoot aConfiguration(
4047 ::utl::OConfigurationTreeRoot::createWithServiceFactory( m_xServiceFactory, sConfigName ) );
4049 sal_Bool bChartEnabled = sal_False;
4050 if ( aConfiguration.hasByHierarchicalName(sPropertyName) )
4051 aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled;
4052 m_bChartEnabled = bChartEnabled;
4054 catch(const Exception&)
4059 // -----------------------------------------------------------------------------
4061 // css.frame.XTitle
4062 ::rtl::OUString SAL_CALL OReportController::getTitle()
4063 throw (uno::RuntimeException)
4065 vos::OGuard aSolarGuard( Application::GetSolarMutex() );
4066 ::osl::MutexGuard aGuard( getMutex() );
4068 uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW);
4070 return xTitle->getTitle ();
4072 // -----------------------------------------------------------------------------
4073 void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
4075 _rDefault <<= sal_Int16(100);
4077 // -----------------------------------------------------------------------------
4078 // comphelper::OPropertyArrayUsageHelper
4079 ::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const
4081 Sequence< Property > aProps;
4082 describeProperties(aProps);
4083 return new ::cppu::OPropertyArrayHelper(aProps);
4085 // -------------------------------------------------------------------------
4087 // cppu::OPropertySetHelper
4088 ::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper()
4090 typedef ::comphelper::OPropertyArrayUsageHelper<OReportController_BASE> OReportController_PROP;
4091 return *OReportController_PROP::getArrayHelper();
4093 // -----------------------------------------------------------------------------
4094 void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue) throw (Exception)
4096 if ( _nHandle == PROPERTY_ID_ZOOMVALUE )
4098 _aValue >>= m_nZoomValue;
4099 impl_zoom_nothrow();
4102 void SAL_CALL OReportController::setMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException)
4104 ::osl::MutexGuard aGuard( getMutex() );
4105 m_sMode = aMode;
4107 ::rtl::OUString SAL_CALL OReportController::getMode( ) throw (::com::sun::star::uno::RuntimeException)
4109 ::osl::MutexGuard aGuard( getMutex() );
4110 return m_sMode;
4112 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OReportController::getSupportedModes( ) throw (::com::sun::star::uno::RuntimeException)
4114 static ::rtl::OUString s_sModes[] = { ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("remote")),
4115 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("normal")) };
4116 return uno::Sequence< ::rtl::OUString> (&s_sModes[0],sizeof(s_sModes)/sizeof(s_sModes[0]));
4118 ::sal_Bool SAL_CALL OReportController::supportsMode( const ::rtl::OUString& aMode ) throw (::com::sun::star::uno::RuntimeException)
4120 uno::Sequence< ::rtl::OUString> aModes = getSupportedModes();
4121 const ::rtl::OUString* pIter = aModes.getConstArray();
4122 const ::rtl::OUString* pEnd = pIter + aModes.getLength();
4123 for(;pIter != pEnd;++pIter)
4125 if ( pIter->equals(aMode ) )
4126 break;
4128 return pIter != pEnd;
4130 // -----------------------------------------------------------------------------
4131 bool OReportController::isUiVisible() const
4133 return !m_sMode.equalsAscii("remote");
4135 // -----------------------------------------------------------------------------
4136 void OReportController::impl_fillState_nothrow(const ::rtl::OUString& _sProperty,dbaui::FeatureState& _rState) const
4138 _rState.bEnabled = isEditable();
4139 if ( _rState.bEnabled )
4141 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4142 m_pMyOwnView->fillControlModelSelection(aSelection);
4143 _rState.bEnabled = !aSelection.empty();
4144 if ( _rState.bEnabled )
4146 uno::Any aTemp;
4147 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
4148 for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter)
4150 uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY);
4153 uno::Any aTemp2 = xProp->getPropertyValue(_sProperty);
4154 if ( aIter == aSelection.begin() )
4156 aTemp = aTemp2;
4158 else if ( !comphelper::compare(aTemp,aTemp2) )
4159 break;
4161 catch(beans::UnknownPropertyException&)
4163 _rState.bEnabled = sal_False;
4165 } // for(; aIter != aSelection.end();++aIter)
4166 if ( aIter == aSelection.end() )
4167 _rState.aValue = aTemp;
4169 } // if ( _rState.bEnabled )
4171 // -----------------------------------------------------------------------------
4172 void OReportController::impl_zoom_nothrow()
4174 Fraction aZoom(m_nZoomValue,100);
4175 setZoomFactor(aZoom,*m_pMyOwnView);
4176 m_pMyOwnView->zoom(aZoom);
4177 // TRY
4178 /*m_pMyOwnView->Invalidate(INVALIDATE_NOCHILDREN);*/
4179 InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(),sal_True);
4180 InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(),sal_True);
4182 // -----------------------------------------------------------------------------
4183 sal_Bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat) const
4185 sal_Bool bRet = sal_False;
4186 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
4190 const awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
4192 switch(_nCommand)
4194 case SID_ATTR_CHAR_WEIGHT:
4195 bRet = awt::FontWeight::BOLD == aFontDescriptor.Weight;
4196 break;
4197 case SID_ATTR_CHAR_POSTURE:
4198 bRet = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
4199 break;
4200 case SID_ATTR_CHAR_UNDERLINE:
4201 bRet = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
4202 break;
4203 default:
4205 } // switch(_nCommand)
4207 catch(uno::Exception&)
4211 return bRet;
4213 // -----------------------------------------------------------------------------
4214 bool OReportController::impl_setPropertyAtControls_throw(const sal_uInt16 _nUndoResId,const ::rtl::OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs)
4216 ::std::auto_ptr<UndoManagerListAction> pListAction;
4217 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4218 uno::Reference< awt::XWindow> xWindow;
4219 lcl_getReportControlFormat(_aArgs,m_pMyOwnView,xWindow,aSelection);
4220 const bool bMultiSet = aSelection.size() > 1;
4221 ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
4222 for(; aIter != aSelection.end();++aIter)
4224 if ( !pListAction.get() && _nUndoResId && bMultiSet )
4226 const String sUndoAction = String(ModuleRes(_nUndoResId));
4227 pListAction.reset(new UndoManagerListAction(m_aUndoManager,sUndoAction));
4228 } // if ( !pListAction.get() )
4229 const uno::Reference< beans::XPropertySet > xControlModel(*aIter,uno::UNO_QUERY);
4230 if ( xControlModel.is() )
4231 xControlModel->setPropertyValue(_sProperty,_aValue);
4232 } // for(; aIter != aSelection.end();++aIter)
4233 return !aSelection.empty();
4235 // -----------------------------------------------------------------------------
4236 void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomShapeType,dbaui::FeatureState& _rState) const
4238 _rState.bEnabled = isEditable();
4239 _rState.bChecked = m_pMyOwnView->GetInsertObj() == OBJ_CUSTOMSHAPE && m_pMyOwnView->GetInsertObjString().compareToAscii(_pCustomShapeType) == 0;
4242 // -----------------------------------------------------------------------------
4243 ::boost::shared_ptr<OSectionWindow> OReportController::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const
4245 if (m_pMyOwnView)
4247 return m_pMyOwnView->getSectionWindow(_xSection);
4250 // throw NullPointerException?
4251 ::boost::shared_ptr<OSectionWindow> pEmpty;
4252 return pEmpty;
4256 // -----------------------------------------------------------------------------
4257 void OReportController::openZoomDialog()
4259 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
4260 if ( pFact )
4262 static SfxItemInfo aItemInfos[] =
4264 { SID_ATTR_ZOOM, SFX_ITEM_POOLABLE }
4266 SfxPoolItem* pDefaults[] =
4268 new SvxZoomItem()
4270 static USHORT pRanges[] =
4272 SID_ATTR_ZOOM,SID_ATTR_ZOOM,
4275 SfxItemPool* pPool( new SfxItemPool(String::CreateFromAscii("ZoomProperties"), SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, pDefaults) );
4276 pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why
4277 pPool->FreezeIdRanges(); // the same
4280 ::std::auto_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
4281 // fill it
4282 SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
4283 aZoomItem.SetValueSet(SVX_ZOOM_ENABLE_100|SVX_ZOOM_ENABLE_WHOLEPAGE|SVX_ZOOM_ENABLE_PAGEWIDTH);
4284 pDescriptor->Put(aZoomItem);
4286 ::std::auto_ptr<AbstractSvxZoomDialog> pDlg( pFact->CreateSvxZoomDialog(NULL, *pDescriptor.get(), RID_SVXDLG_ZOOM) );
4287 pDlg->SetLimits( 20, 400 );
4288 bool bCancel = ( RET_CANCEL == pDlg->Execute() );
4290 if ( !bCancel )
4292 const SvxZoomItem& rZoomItem = (const SvxZoomItem&)pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM );
4293 m_eZoomType = rZoomItem.GetType();
4294 m_nZoomValue = rZoomItem.GetValue();
4295 if ( m_eZoomType != SVX_ZOOM_PERCENT )
4296 m_nZoomValue = m_pMyOwnView->getZoomFactor( m_eZoomType );
4298 impl_zoom_nothrow();
4299 } // if ( !bCancel )
4301 catch(uno::Exception&)
4303 DBG_UNHANDLED_EXCEPTION();
4305 SfxItemPool::Free(pPool);
4307 for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
4308 delete pDefaults[i];
4309 } // if(pFact)
4311 // -----------------------------------------------------------------------------
4312 // -----------------------------------------------------------------------------
4313 // XVisualObject
4314 void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4316 ::osl::MutexGuard aGuard( getMutex() );
4317 //if( nAspect == embed::Aspects::MSOLE_CONTENT )
4319 bool bChanged =
4320 (m_aVisualAreaSize.Width != _aSize.Width ||
4321 m_aVisualAreaSize.Height != _aSize.Height);
4322 m_aVisualAreaSize = _aSize;
4323 if( bChanged )
4324 setModified( sal_True );
4326 m_nAspect = _nAspect;
4328 // -----------------------------------------------------------------------------
4329 awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4331 ::osl::MutexGuard aGuard( getMutex() );
4332 return m_aVisualAreaSize;
4334 // -----------------------------------------------------------------------------
4335 embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect ) throw (lang::IllegalArgumentException, embed::WrongStateException, uno::Exception, uno::RuntimeException)
4337 ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
4338 ::osl::MutexGuard aGuard( getMutex() );
4339 embed::VisualRepresentation aResult;
4340 if ( !m_bInGeneratePreview )
4342 m_bInGeneratePreview = true;
4345 if ( !m_xReportEngine.is() )
4346 m_xReportEngine.set(getORB()->createInstance(SERVICE_REPORTENGINE),uno::UNO_QUERY_THROW);
4347 const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows();
4348 m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW);
4349 m_xReportEngine->setReportDefinition(m_xReportDefinition);
4350 m_xReportEngine->setActiveConnection(getConnection());
4353 Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY);
4354 if ( xTransfer.is() )
4356 xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize);
4357 aResult = xTransfer->getPreferredVisualRepresentation( _nAspect );
4358 } // if ( xTransfer.is() )
4360 catch( uno::Exception & ex )
4362 (void)ex;
4364 m_xReportEngine->setMaxRows(nOldMaxRows);
4366 catch( uno::Exception & ex )
4368 (void)ex;
4370 m_bInGeneratePreview = false;
4372 return aResult;
4374 // -----------------------------------------------------------------------------
4375 ::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ ) throw (uno::Exception, uno::RuntimeException)
4377 return embed::EmbedMapUnits::ONE_100TH_MM;