bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / report / ReportController.cxx
blob315061709c5e3bf6c7eed829c75be96ed1822df9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <ReportController.hxx>
21 #include <ReportDefinition.hxx>
22 #include <CondFormat.hxx>
23 #include <UITools.hxx>
24 #include <AddField.hxx>
25 #include <toolkit/helper/vclunohelper.hxx>
26 #include <DateTime.hxx>
28 #include <sfx2/filedlghelper.hxx>
29 #include <tools/diagnose_ex.h>
30 #include <rptui_slotid.hrc>
31 #include <reportformula.hxx>
33 #include <comphelper/documentconstants.hxx>
34 #include <unotools/mediadescriptor.hxx>
35 #include <comphelper/property.hxx>
36 #include <comphelper/propertysequence.hxx>
37 #include <comphelper/sequenceashashmap.hxx>
38 #include <comphelper/types.hxx>
40 #include <connectivity/dbtools.hxx>
41 #include <com/sun/star/view/PaperFormat.hpp>
42 #include <com/sun/star/style/GraphicLocation.hpp>
43 #include <com/sun/star/style/XStyle.hpp>
44 #include <com/sun/star/style/PageStyleLayout.hpp>
45 #include <com/sun/star/style/ParagraphAdjust.hpp>
46 #include <com/sun/star/util/NumberFormatter.hpp>
47 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
48 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
49 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
50 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
51 #include <com/sun/star/frame/FrameSearchFlag.hpp>
52 #include <com/sun/star/datatransfer/XTransferable.hpp>
53 #include <com/sun/star/container/XChild.hpp>
54 #include <com/sun/star/container/XNameContainer.hpp>
55 #include <com/sun/star/report/XImageControl.hpp>
56 #include <com/sun/star/report/XFixedLine.hpp>
57 #include <com/sun/star/report/Function.hpp>
58 #include <com/sun/star/awt/FontDescriptor.hpp>
59 #include <com/sun/star/sdb/XDocumentDataSource.hpp>
60 #include <com/sun/star/sdb/XParametersSupplier.hpp>
61 #include <com/sun/star/sdb/CommandType.hpp>
62 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
63 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
64 #include <com/sun/star/embed/ElementModes.hpp>
65 #include <com/sun/star/embed/EmbedMapUnits.hpp>
66 #include <com/sun/star/awt/FontWeight.hpp>
67 #include <com/sun/star/awt/FontUnderline.hpp>
68 #include <com/sun/star/awt/TextAlign.hpp>
69 #include <com/sun/star/awt/FontSlant.hpp>
70 #include <com/sun/star/frame/Desktop.hpp>
71 #include <com/sun/star/frame/status/FontHeight.hpp>
72 #include <com/sun/star/report/ReportEngine.hpp>
73 #include <com/sun/star/report/XFormattedField.hpp>
74 #include <com/sun/star/sdb/SQLContext.hpp>
75 #include <com/sun/star/sdbc/SQLWarning.hpp>
76 #include <com/sun/star/beans/PropertyAttribute.hpp>
77 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
79 #include <vcl/svapp.hxx>
80 #include <vcl/waitobj.hxx>
82 #include <svx/fmview.hxx>
83 #include <editeng/paperinf.hxx>
84 #include <editeng/memberids.h>
85 #include <svx/svxids.hrc>
86 #include <svx/svdobj.hxx>
87 #include <svx/dataaccessdescriptor.hxx>
88 #include <svx/xflclit.hxx>
89 #include <svx/xflgrit.hxx>
90 #include <svx/xflhtit.hxx>
91 #include <svx/xbtmpit.hxx>
92 #include <svx/xflftrit.hxx>
93 #include <svx/xsflclit.hxx>
94 #include <svx/xflbckit.hxx>
95 #include <svx/xflbmpit.hxx>
96 #include <svx/xflbmsli.hxx>
97 #include <svx/xflbmsxy.hxx>
98 #include <svx/xflbmtit.hxx>
99 #include <svx/xflboxy.hxx>
100 #include <svx/xflbstit.hxx>
101 #include <svx/xflbtoxy.hxx>
102 #include <svx/xfltrit.hxx>
103 #include <svx/xgrscit.hxx>
104 #include <editeng/svxenum.hxx>
105 #include <svx/pageitem.hxx>
106 #include <editeng/lrspitem.hxx>
107 #include <editeng/ulspitem.hxx>
108 #include <editeng/sizeitem.hxx>
109 #include <sfx2/zoomitem.hxx>
110 #include <svx/zoomslideritem.hxx>
111 #include <editeng/brushitem.hxx>
112 #include <svx/flagsdef.hxx>
113 #include <svx/svdpagv.hxx>
114 #include <svx/svxdlg.hxx>
115 #include <svx/zoom_def.hxx>
116 #include <svx/dialogs.hrc>
118 #include <core_resource.hxx>
119 #include <DesignView.hxx>
120 #include <RptObject.hxx>
121 #include <RptUndo.hxx>
122 #include <strings.hxx>
123 #include <RptDef.hxx>
124 #include <ReportSection.hxx>
125 #include <SectionView.hxx>
126 #include <UndoActions.hxx>
127 #include <dlgpage.hxx>
128 #include <strings.hrc>
130 #include <svl/itempool.hxx>
131 #include <svl/itemset.hxx>
132 #include <svl/aeitem.hxx>
133 #include <svtools/cliplistener.hxx>
134 #include <unotools/syslocale.hxx>
135 #include <unotools/viewoptions.hxx>
136 #include <unotools/localedatawrapper.hxx>
138 #include <osl/mutex.hxx>
139 #include <PropertyForward.hxx>
140 #include <SectionWindow.hxx>
142 #include <toolkit/helper/convert.hxx>
143 #include <GroupsSorting.hxx>
144 #include <PageNumber.hxx>
145 #include <UndoEnv.hxx>
147 #include <memory>
149 #include <cppuhelper/exc_hlp.hxx>
150 #include <unotools/confignode.hxx>
152 #include <ReportControllerObserver.hxx>
154 #define MAX_ROWS_FOR_PREVIEW 20
156 #define RPTUI_ID_LRSPACE XATTR_FILL_FIRST - 8
157 #define RPTUI_ID_ULSPACE XATTR_FILL_FIRST - 7
158 #define RPTUI_ID_PAGE XATTR_FILL_FIRST - 6
159 #define RPTUI_ID_SIZE XATTR_FILL_FIRST - 5
160 #define RPTUI_ID_PAGE_MODE XATTR_FILL_FIRST - 4
161 #define RPTUI_ID_START XATTR_FILL_FIRST - 3
162 #define RPTUI_ID_END XATTR_FILL_FIRST - 2
163 #define RPTUI_ID_BRUSH XATTR_FILL_FIRST - 1
164 #define RPTUI_ID_METRIC XATTR_FILL_LAST + 1
166 using namespace ::com::sun::star;
167 using namespace uno;
168 using namespace io;
169 using namespace beans;
170 using namespace frame;
171 using namespace util;
172 using namespace lang;
173 using namespace container;
174 using namespace sdbcx;
175 using namespace sdbc;
176 using namespace sdb;
177 using namespace ui;
178 using namespace ui::dialogs;
179 using namespace ::dbtools;
180 using namespace ::rptui;
181 using namespace ::dbaui;
182 using namespace ::comphelper;
183 using namespace ::cppu;
186 namespace
188 void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId)
190 if ( _xReportControlFormat.is() )
194 awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
195 switch(_nId)
197 case SID_ATTR_CHAR_WEIGHT:
198 aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight;
199 break;
200 case SID_ATTR_CHAR_POSTURE:
201 aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant));
202 break;
203 case SID_ATTR_CHAR_UNDERLINE:
204 aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline;
205 break;
206 default:
207 OSL_FAIL("Illegal value in default!");
208 break;
211 _xReportControlFormat->setFontDescriptor(aFontDescriptor);
213 catch(const beans::UnknownPropertyException&)
221 static void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,
222 ODesignView* _pView,
223 uno::Reference< awt::XWindow>& _xWindow,
224 ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats)
226 uno::Reference< report::XReportControlFormat> xReportControlFormat;
227 if ( aArgs.hasElements() )
229 SequenceAsHashMap aMap(aArgs);
230 xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>());
231 _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>());
234 if ( !xReportControlFormat.is() )
236 _pView->fillControlModelSelection(_rControlsFormats);
238 else
240 uno::Reference<uno::XInterface> xInterface(xReportControlFormat);
241 _rControlsFormats.push_back(xInterface);
244 if ( !_xWindow.is() )
245 _xWindow = VCLUnoHelper::GetInterface(_pView);
248 OUString SAL_CALL OReportController::getImplementationName()
250 return getImplementationName_Static();
254 OUString OReportController::getImplementationName_Static()
256 return OUString("com.sun.star.report.comp.ReportDesign");
259 Sequence< OUString> OReportController::getSupportedServiceNames_Static()
261 Sequence<OUString> aSupported { "com.sun.star.sdb.ReportDesign" };
262 return aSupported;
265 Sequence< OUString> SAL_CALL OReportController::getSupportedServiceNames()
267 return getSupportedServiceNames_Static();
270 Reference< XInterface > OReportController::create(Reference< XComponentContext > const & xContext)
272 return *(new OReportController(xContext));
275 #define PROPERTY_ID_ZOOMVALUE 1
278 OReportController::OReportController(Reference< XComponentContext > const & xContext)
279 :OReportController_BASE(xContext)
280 ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper)
281 ,m_aSelectionListeners( getMutex() )
282 ,m_pGroupsFloater(nullptr)
283 ,m_sMode("normal")
284 ,m_nSplitPos(-1)
285 ,m_nPageNum(-1)
286 ,m_nSelectionCount(0)
287 ,m_nAspect(0)
288 ,m_nZoomValue(100)
289 ,m_eZoomType(SvxZoomType::PERCENT)
290 ,m_bShowRuler(true)
291 ,m_bGridVisible(true)
292 ,m_bGridUse(true)
293 ,m_bShowProperties(true)
294 ,m_bHelplinesMove(true)
295 ,m_bChartEnabled(false)
296 ,m_bChartEnabledAsked(false)
297 ,m_bInGeneratePreview(false)
299 // new Observer
300 m_pReportControllerObserver = new OXReportControllerObserver(*this);
301 registerProperty("ZoomValue", PROPERTY_ID_ZOOMVALUE,
302 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::TRANSIENT,
303 &m_nZoomValue, ::cppu::UnoType<sal_Int16>::get());
307 OReportController::~OReportController()
311 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)
312 IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener)
314 void OReportController::disposing()
317 if ( m_pClipboardNotifier.is() )
319 m_pClipboardNotifier->ClearCallbackLink();
320 m_pClipboardNotifier->RemoveListener( getView() );
321 m_pClipboardNotifier.clear();
323 if ( m_pGroupsFloater )
325 SvtViewOptions aDlgOpt(EViewType::Window, OStringToOUString(m_pGroupsFloater->GetHelpId(), RTL_TEXTENCODING_UTF8));
326 aDlgOpt.SetWindowState(OStringToOUString(m_pGroupsFloater->GetWindowState(), RTL_TEXTENCODING_ASCII_US));
327 m_pGroupsFloater.disposeAndClear();
332 m_xHoldAlive.clear();
333 m_xColumns.clear();
334 ::comphelper::disposeComponent( m_xRowSet );
335 ::comphelper::disposeComponent( m_xRowSetMediator );
336 ::comphelper::disposeComponent( m_xFormatter );
338 catch(const uno::Exception&)
340 OSL_FAIL("Exception caught while disposing row sets.");
342 m_xRowSet.clear();
343 m_xRowSetMediator.clear();
345 if ( m_xReportDefinition.is() )
349 OSectionWindow* pSectionWindow = nullptr;
350 if ( getDesignView() )
351 pSectionWindow = getDesignView()->getMarkedSection();
352 if ( pSectionWindow )
353 pSectionWindow->getReportSection().deactivateOle();
354 clearUndoManager();
355 if ( m_aReportModel )
356 listen(false);
357 m_pReportControllerObserver->Clear();
358 m_pReportControllerObserver.clear();
360 catch(const uno::Exception&)
362 DBG_UNHANDLED_EXCEPTION("reportdesign");
367 EventObject aDisposingEvent( *this );
368 m_aSelectionListeners.disposeAndClear( aDisposingEvent );
371 OReportController_BASE::disposing();
376 m_xReportDefinition.clear();
377 m_aReportModel.reset();
378 m_xFrameLoader.clear();
379 m_xReportEngine.clear();
381 catch(const uno::Exception&)
384 if ( getDesignView() )
385 EndListening( *getDesignView() );
386 clearView();
389 FeatureState OReportController::GetState(sal_uInt16 _nId) const
391 FeatureState aReturn;
392 // (disabled automatically)
393 aReturn.bEnabled = false;
394 // check this first
395 if ( !getView() )
396 return aReturn;
398 switch (_nId)
400 case SID_RPT_TEXTDOCUMENT:
401 aReturn.bEnabled = isEditable();
402 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII);
403 break;
404 case SID_RPT_SPREADSHEET:
405 aReturn.bEnabled = isEditable();
406 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII);
407 break;
408 case SID_REPORTHEADER_WITHOUT_UNDO:
409 case SID_REPORTFOOTER_WITHOUT_UNDO:
410 case SID_REPORTHEADERFOOTER:
412 aReturn.bEnabled = isEditable();
413 OUString sText = RptResId((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT);
414 aReturn.sTitle = sText;
416 break;
417 case SID_PAGEHEADER_WITHOUT_UNDO:
418 case SID_PAGEFOOTER_WITHOUT_UNDO:
419 case SID_PAGEHEADERFOOTER:
421 aReturn.bEnabled = isEditable();
422 OUString sText = RptResId((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT);
423 aReturn.sTitle = sText;
425 break;
426 case SID_GROUP_APPEND:
427 case SID_GROUP_REMOVE:
428 case SID_GROUPHEADER_WITHOUT_UNDO:
429 case SID_GROUPHEADER:
430 case SID_GROUPFOOTER_WITHOUT_UNDO:
431 case SID_GROUPFOOTER:
432 aReturn.bEnabled = isEditable();
433 break;
434 case SID_ADD_CONTROL_PAIR:
435 aReturn.bEnabled = isEditable();
436 break;
437 case SID_REDO:
438 case SID_UNDO:
440 size_t ( SfxUndoManager::*retrieveCount )( bool const ) const =
441 ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount;
443 SfxUndoManager& rUndoManager( getUndoManager() );
444 aReturn.bEnabled = ( rUndoManager.*retrieveCount )( SfxUndoManager::TopLevel ) > 0;
445 if ( aReturn.bEnabled )
447 // TODO: add "Undo/Redo: prefix"
448 OUString ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const =
449 ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment;
450 aReturn.sTitle = (rUndoManager.*retrieveComment)( 0, SfxUndoManager::TopLevel );
453 break;
454 case SID_OBJECT_RESIZING:
455 case SID_OBJECT_SMALLESTWIDTH:
456 case SID_OBJECT_SMALLESTHEIGHT:
457 case SID_OBJECT_GREATESTWIDTH:
458 case SID_OBJECT_GREATESTHEIGHT:
459 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
460 if ( aReturn.bEnabled )
461 aReturn.bEnabled = m_nSelectionCount > 1;
462 break;
464 case SID_DISTRIBUTION:
465 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
466 if ( aReturn.bEnabled )
468 OSectionView* pSectionView = getCurrentSectionView();
469 aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2;
471 break;
472 case SID_ARRANGEMENU:
473 case SID_FRAME_DOWN:
474 case SID_FRAME_UP:
475 case SID_FRAME_TO_TOP:
476 case SID_FRAME_TO_BOTTOM:
477 case SID_OBJECT_HEAVEN:
478 case SID_OBJECT_HELL:
479 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
480 if ( aReturn.bEnabled )
482 OSectionView* pSectionView = getCurrentSectionView();
483 aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked();
484 if ( aReturn.bEnabled )
486 if ( SID_OBJECT_HEAVEN == _nId )
487 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT;
488 else if ( SID_OBJECT_HELL == _nId )
489 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK;
492 break;
494 case SID_SECTION_SHRINK:
495 case SID_SECTION_SHRINK_TOP:
496 case SID_SECTION_SHRINK_BOTTOM:
498 sal_Int32 nCount = 0;
499 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
500 if ( xSection.is() )
502 nCount = xSection->getCount();
504 aReturn.bEnabled = isEditable() && nCount > 0;
506 break;
507 case SID_OBJECT_ALIGN:
508 case SID_OBJECT_ALIGN_LEFT:
509 case SID_OBJECT_ALIGN_CENTER:
510 case SID_OBJECT_ALIGN_RIGHT:
511 case SID_OBJECT_ALIGN_UP:
512 case SID_OBJECT_ALIGN_MIDDLE:
513 case SID_OBJECT_ALIGN_DOWN:
514 case SID_SECTION_ALIGN:
515 case SID_SECTION_ALIGN_LEFT:
516 case SID_SECTION_ALIGN_CENTER:
517 case SID_SECTION_ALIGN_RIGHT:
518 case SID_SECTION_ALIGN_UP:
519 case SID_SECTION_ALIGN_MIDDLE:
520 case SID_SECTION_ALIGN_DOWN:
521 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
522 break;
523 case SID_CUT:
524 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
525 break;
526 case SID_COPY:
527 aReturn.bEnabled = getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
528 break;
529 case SID_PASTE:
530 aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent() && getDesignView()->IsPasteAllowed();
531 break;
532 case SID_SELECTALL:
533 aReturn.bEnabled = !getDesignView()->isHandleEvent();
534 break;
535 case SID_SELECTALL_IN_SECTION:
536 aReturn.bEnabled = !getDesignView()->isHandleEvent();
537 if ( aReturn.bEnabled )
538 aReturn.bEnabled = getCurrentSectionView() != nullptr;
539 break;
540 case SID_ESCAPE:
541 aReturn.bEnabled = getDesignView()->GetMode() == DlgEdMode::Insert;
542 break;
543 case SID_TERMINATE_INPLACEACTIVATION:
544 aReturn.bEnabled = true;
545 break;
546 case SID_SELECT_ALL_EDITS:
547 case SID_SELECT_ALL_LABELS:
548 aReturn.bEnabled = true;
549 break;
550 case SID_RPT_NEW_FUNCTION:
551 aReturn.bEnabled = isEditable();
552 break;
553 case SID_COLLAPSE_SECTION:
554 case SID_EXPAND_SECTION:
555 case SID_NEXT_MARK:
556 case SID_PREV_MARK:
557 aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent();
558 break;
559 case SID_SELECT:
560 case SID_SELECT_REPORT:
561 aReturn.bEnabled = true;
562 break;
563 case SID_EXECUTE_REPORT:
564 aReturn.bEnabled = isConnected() && m_xReportDefinition.is();
565 break;
566 case SID_DELETE:
567 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
568 if ( aReturn.bEnabled )
570 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
571 if ( pSectionWindow )
572 aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive();
575 OUString sText = RptResId(RID_STR_DELETE);
576 aReturn.sTitle = sText;
578 break;
579 case SID_GRID_VISIBLE:
580 aReturn.bEnabled = isEditable();
581 aReturn.bChecked = m_bGridVisible;
582 break;
583 case SID_GRID_USE:
584 aReturn.bEnabled = isEditable();
585 aReturn.bChecked = m_bGridUse;
586 break;
587 case SID_HELPLINES_MOVE:
588 aReturn.bEnabled = isEditable();
589 aReturn.bChecked = m_bHelplinesMove;
590 break;
591 case SID_RULER:
592 aReturn.bEnabled = isEditable();
593 aReturn.bChecked = m_bShowRuler;
594 break;
595 case SID_OBJECT_SELECT:
596 aReturn.bEnabled = true;
597 aReturn.bChecked = getDesignView()->GetMode() == DlgEdMode::Select;
598 break;
599 case SID_INSERT_DIAGRAM:
600 aReturn.bEnabled = isEditable();
601 aReturn.bInvisible = !m_bChartEnabled;
602 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_OLE2;
603 break;
604 case SID_FM_FIXEDTEXT:
605 aReturn.bEnabled = isEditable();
606 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FIXEDTEXT;
607 break;
608 case SID_INSERT_HFIXEDLINE:
609 aReturn.bEnabled = isEditable();
610 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_HFIXEDLINE;
611 break;
612 case SID_INSERT_VFIXEDLINE:
613 aReturn.bEnabled = isEditable();
614 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_VFIXEDLINE;
615 break;
616 case SID_FM_EDIT:
617 aReturn.bEnabled = isEditable();
618 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_FORMATTEDFIELD;
619 break;
620 case SID_FM_IMAGECONTROL:
621 aReturn.bEnabled = isEditable();
622 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_DLG_IMAGECONTROL;
623 break;
624 case SID_DRAWTBX_CS_BASIC:
625 case SID_DRAWTBX_CS_BASIC1:
626 case SID_DRAWTBX_CS_BASIC2:
627 case SID_DRAWTBX_CS_BASIC3:
628 case SID_DRAWTBX_CS_BASIC4:
629 case SID_DRAWTBX_CS_BASIC5:
630 case SID_DRAWTBX_CS_BASIC6:
631 case SID_DRAWTBX_CS_BASIC7:
632 case SID_DRAWTBX_CS_BASIC8:
633 case SID_DRAWTBX_CS_BASIC9:
634 case SID_DRAWTBX_CS_BASIC10:
635 case SID_DRAWTBX_CS_BASIC11:
636 case SID_DRAWTBX_CS_BASIC12:
637 case SID_DRAWTBX_CS_BASIC13:
638 case SID_DRAWTBX_CS_BASIC14:
639 case SID_DRAWTBX_CS_BASIC15:
640 case SID_DRAWTBX_CS_BASIC16:
641 case SID_DRAWTBX_CS_BASIC17:
642 case SID_DRAWTBX_CS_BASIC18:
643 case SID_DRAWTBX_CS_BASIC19:
644 case SID_DRAWTBX_CS_BASIC20:
645 case SID_DRAWTBX_CS_BASIC21:
646 case SID_DRAWTBX_CS_BASIC22:
647 impl_fillCustomShapeState_nothrow("diamond",aReturn);
648 break;
649 case SID_DRAWTBX_CS_SYMBOL:
650 case SID_DRAWTBX_CS_SYMBOL1:
651 case SID_DRAWTBX_CS_SYMBOL2:
652 case SID_DRAWTBX_CS_SYMBOL3:
653 case SID_DRAWTBX_CS_SYMBOL4:
654 case SID_DRAWTBX_CS_SYMBOL5:
655 case SID_DRAWTBX_CS_SYMBOL6:
656 case SID_DRAWTBX_CS_SYMBOL7:
657 case SID_DRAWTBX_CS_SYMBOL8:
658 case SID_DRAWTBX_CS_SYMBOL9:
659 case SID_DRAWTBX_CS_SYMBOL10:
660 case SID_DRAWTBX_CS_SYMBOL11:
661 case SID_DRAWTBX_CS_SYMBOL12:
662 case SID_DRAWTBX_CS_SYMBOL13:
663 case SID_DRAWTBX_CS_SYMBOL14:
664 case SID_DRAWTBX_CS_SYMBOL15:
665 case SID_DRAWTBX_CS_SYMBOL16:
666 case SID_DRAWTBX_CS_SYMBOL17:
667 case SID_DRAWTBX_CS_SYMBOL18:
668 impl_fillCustomShapeState_nothrow("smiley",aReturn);
669 break;
670 case SID_DRAWTBX_CS_ARROW:
671 case SID_DRAWTBX_CS_ARROW1:
672 case SID_DRAWTBX_CS_ARROW2:
673 case SID_DRAWTBX_CS_ARROW3:
674 case SID_DRAWTBX_CS_ARROW4:
675 case SID_DRAWTBX_CS_ARROW5:
676 case SID_DRAWTBX_CS_ARROW6:
677 case SID_DRAWTBX_CS_ARROW7:
678 case SID_DRAWTBX_CS_ARROW8:
679 case SID_DRAWTBX_CS_ARROW9:
680 case SID_DRAWTBX_CS_ARROW10:
681 case SID_DRAWTBX_CS_ARROW11:
682 case SID_DRAWTBX_CS_ARROW12:
683 case SID_DRAWTBX_CS_ARROW13:
684 case SID_DRAWTBX_CS_ARROW14:
685 case SID_DRAWTBX_CS_ARROW15:
686 case SID_DRAWTBX_CS_ARROW16:
687 case SID_DRAWTBX_CS_ARROW17:
688 case SID_DRAWTBX_CS_ARROW18:
689 case SID_DRAWTBX_CS_ARROW19:
690 case SID_DRAWTBX_CS_ARROW20:
691 case SID_DRAWTBX_CS_ARROW21:
692 case SID_DRAWTBX_CS_ARROW22:
693 case SID_DRAWTBX_CS_ARROW23:
694 case SID_DRAWTBX_CS_ARROW24:
695 case SID_DRAWTBX_CS_ARROW25:
696 case SID_DRAWTBX_CS_ARROW26:
697 impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn);
698 break;
699 case SID_DRAWTBX_CS_STAR:
700 case SID_DRAWTBX_CS_STAR1:
701 case SID_DRAWTBX_CS_STAR2:
702 case SID_DRAWTBX_CS_STAR3:
703 case SID_DRAWTBX_CS_STAR4:
704 case SID_DRAWTBX_CS_STAR5:
705 case SID_DRAWTBX_CS_STAR6:
706 case SID_DRAWTBX_CS_STAR7:
707 case SID_DRAWTBX_CS_STAR8:
708 case SID_DRAWTBX_CS_STAR9:
709 case SID_DRAWTBX_CS_STAR10:
710 case SID_DRAWTBX_CS_STAR11:
711 case SID_DRAWTBX_CS_STAR12:
712 impl_fillCustomShapeState_nothrow("star5",aReturn);
713 break;
714 case SID_DRAWTBX_CS_FLOWCHART:
715 case SID_DRAWTBX_CS_FLOWCHART1:
716 case SID_DRAWTBX_CS_FLOWCHART2:
717 case SID_DRAWTBX_CS_FLOWCHART3:
718 case SID_DRAWTBX_CS_FLOWCHART4:
719 case SID_DRAWTBX_CS_FLOWCHART5:
720 case SID_DRAWTBX_CS_FLOWCHART6:
721 case SID_DRAWTBX_CS_FLOWCHART7:
722 case SID_DRAWTBX_CS_FLOWCHART8:
723 case SID_DRAWTBX_CS_FLOWCHART9:
724 case SID_DRAWTBX_CS_FLOWCHART10:
725 case SID_DRAWTBX_CS_FLOWCHART11:
726 case SID_DRAWTBX_CS_FLOWCHART12:
727 case SID_DRAWTBX_CS_FLOWCHART13:
728 case SID_DRAWTBX_CS_FLOWCHART14:
729 case SID_DRAWTBX_CS_FLOWCHART15:
730 case SID_DRAWTBX_CS_FLOWCHART16:
731 case SID_DRAWTBX_CS_FLOWCHART17:
732 case SID_DRAWTBX_CS_FLOWCHART18:
733 case SID_DRAWTBX_CS_FLOWCHART19:
734 case SID_DRAWTBX_CS_FLOWCHART20:
735 case SID_DRAWTBX_CS_FLOWCHART21:
736 case SID_DRAWTBX_CS_FLOWCHART22:
737 case SID_DRAWTBX_CS_FLOWCHART23:
738 case SID_DRAWTBX_CS_FLOWCHART24:
739 case SID_DRAWTBX_CS_FLOWCHART25:
740 case SID_DRAWTBX_CS_FLOWCHART26:
741 case SID_DRAWTBX_CS_FLOWCHART27:
742 case SID_DRAWTBX_CS_FLOWCHART28:
743 impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn);
744 break;
745 case SID_DRAWTBX_CS_CALLOUT:
746 case SID_DRAWTBX_CS_CALLOUT1:
747 case SID_DRAWTBX_CS_CALLOUT2:
748 case SID_DRAWTBX_CS_CALLOUT3:
749 case SID_DRAWTBX_CS_CALLOUT4:
750 case SID_DRAWTBX_CS_CALLOUT5:
751 case SID_DRAWTBX_CS_CALLOUT6:
752 case SID_DRAWTBX_CS_CALLOUT7:
753 impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn);
754 break;
755 case SID_RPT_SHOWREPORTEXPLORER:
756 aReturn.bEnabled = m_xReportDefinition.is();
757 aReturn.bChecked = getDesignView() && getDesignView()->isReportExplorerVisible();
758 break;
759 case SID_FM_ADD_FIELD:
760 aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is()
761 && !m_xReportDefinition->getCommand().isEmpty();
762 aReturn.bChecked = getDesignView() && getDesignView()->isAddFieldVisible();
763 break;
764 case SID_SHOW_PROPERTYBROWSER:
765 aReturn.bEnabled = true;
766 aReturn.bChecked = m_bShowProperties;
767 break;
768 case SID_PROPERTYBROWSER_LAST_PAGE:
769 aReturn.bEnabled = true;
770 aReturn.aValue <<= m_sLastActivePage;
771 break;
772 case SID_SPLIT_POSITION:
773 aReturn.bEnabled = true;
774 aReturn.aValue <<= getSplitPos();
775 break;
776 case SID_SAVEDOC:
777 case SID_SAVEASDOC:
778 case SID_SAVEACOPY:
779 aReturn.bEnabled = isConnected() && isEditable();
780 break;
781 case SID_EDITDOC:
782 aReturn.bChecked = isEditable();
783 break;
784 case SID_PAGEDIALOG:
785 aReturn.bEnabled = isEditable();
786 break;
787 case SID_BACKGROUND_COLOR:
788 impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn);
789 break;
790 case SID_ATTR_CHAR_COLOR_BACKGROUND:
791 aReturn.bEnabled = isEditable();
793 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
794 if ( xSection.is() )
797 aReturn.aValue <<= xSection->getBackColor();
798 const uno::Reference< report::XReportControlModel> xControlModel(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
799 aReturn.bEnabled = !xControlModel.is();
801 catch(const beans::UnknownPropertyException&)
804 else
805 aReturn.bEnabled = false;
807 break;
808 case SID_SORTINGANDGROUPING:
809 aReturn.bEnabled = true;
810 aReturn.bChecked = m_pGroupsFloater && m_pGroupsFloater->IsVisible();
811 break;
812 case SID_ATTR_CHAR_WEIGHT:
813 case SID_ATTR_CHAR_POSTURE:
814 case SID_ATTR_CHAR_UNDERLINE:
815 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
816 if ( aReturn.bEnabled )
818 awt::FontDescriptor aFontDescriptor;
819 aReturn.aValue >>= aFontDescriptor;
820 aReturn.aValue.clear();
822 switch(_nId)
824 case SID_ATTR_CHAR_WEIGHT:
825 aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight;
826 break;
827 case SID_ATTR_CHAR_POSTURE:
828 aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
829 break;
830 case SID_ATTR_CHAR_UNDERLINE:
831 aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
832 break;
833 default:
837 break;
838 case SID_ATTR_CHAR_COLOR:
839 case SID_ATTR_CHAR_COLOR2:
840 impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn);
841 break;
842 case SID_ATTR_CHAR_FONT:
843 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
844 break;
845 case SID_ATTR_CHAR_FONTHEIGHT:
846 impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn);
847 if ( aReturn.aValue.hasValue() )
849 frame::status::FontHeight aFontHeight;
850 aReturn.aValue >>= aFontHeight.Height;
851 aReturn.aValue <<= aFontHeight; // another type is needed here, so
853 break;
854 case SID_ATTR_PARA_ADJUST_LEFT:
855 case SID_ATTR_PARA_ADJUST_CENTER:
856 case SID_ATTR_PARA_ADJUST_RIGHT:
857 case SID_ATTR_PARA_ADJUST_BLOCK:
858 impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn);
859 if ( aReturn.bEnabled )
861 ::sal_Int16 nParaAdjust = 0;
862 if ( aReturn.aValue >>= nParaAdjust )
864 switch(static_cast<style::ParagraphAdjust>(nParaAdjust))
866 case style::ParagraphAdjust_LEFT:
867 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT;
868 break;
869 case style::ParagraphAdjust_RIGHT:
870 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT;
871 break;
872 case style::ParagraphAdjust_BLOCK:
873 case style::ParagraphAdjust_STRETCH:
874 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK;
875 break;
876 case style::ParagraphAdjust_CENTER:
877 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER;
878 break;
879 default: break;
882 aReturn.aValue.clear();
884 break;
886 case SID_INSERT_GRAPHIC:
887 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
888 break;
889 case SID_CHAR_DLG:
890 case SID_SETCONTROLDEFAULTS:
891 aReturn.bEnabled = m_xReportDefinition.is() && isEditable();
892 if ( aReturn.bEnabled )
894 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
895 getDesignView()->fillControlModelSelection(aSelection);
896 aReturn.bEnabled = !aSelection.empty()
897 && std::all_of(aSelection.begin(), aSelection.end(), [](const uno::Reference<uno::XInterface>& rxInterface) {
898 return !uno::Reference<report::XFixedLine>(rxInterface, uno::UNO_QUERY).is()
899 && !uno::Reference<report::XImageControl>(rxInterface, uno::UNO_QUERY).is()
900 && uno::Reference<report::XReportControlFormat>(rxInterface, uno::UNO_QUERY).is(); });
902 break;
903 case SID_CONDITIONALFORMATTING:
905 const uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
906 aReturn.bEnabled = xFormattedField.is();
908 break;
909 case SID_INSERT_FLD_PGNUMBER:
910 case SID_DATETIME:
911 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
912 break;
913 case SID_EXPORTDOC:
914 case SID_EXPORTDOCASPDF:
915 aReturn.bEnabled = m_xReportDefinition.is();
916 break;
917 case SID_PRINTPREVIEW:
918 aReturn.bEnabled = false;
919 break;
920 case SID_ATTR_ZOOM:
921 aReturn.bEnabled = true;
923 SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
924 aZoom.SetValueSet(SvxZoomEnableFlags::N50|SvxZoomEnableFlags::N75|SvxZoomEnableFlags::N100|SvxZoomEnableFlags::N200);
925 aZoom.QueryValue(aReturn.aValue);
927 break;
928 case SID_ATTR_ZOOMSLIDER:
929 aReturn.bEnabled = true;
931 SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400);
932 aZoomSlider.AddSnappingPoint(50);
933 aZoomSlider.AddSnappingPoint(75);
934 aZoomSlider.AddSnappingPoint(100);
935 aZoomSlider.AddSnappingPoint(200);
936 aZoomSlider.QueryValue(aReturn.aValue);
938 break;
939 default:
940 aReturn = OReportController_BASE::GetState(_nId);
942 return aReturn;
946 namespace
948 /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call
950 The dispatch might originate from either the toolbar, or the conditional
951 formatting dialog. In both cases, argument formats are different.
953 util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs )
955 util::Color aColor( COL_TRANSPARENT );
956 if ( _rDispatchArgs.getLength() == 1 )
958 OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor );
960 else
962 SequenceAsHashMap aMap( _rDispatchArgs );
963 aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor );
965 return aColor;
970 void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
972 SolarMutexGuard aSolarGuard;
973 ::osl::MutexGuard aGuard( getMutex() );
975 bool bForceBroadcast = false;
976 switch(_nId)
978 case SID_RPT_TEXTDOCUMENT:
979 if ( m_xReportDefinition.is() )
980 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII );
981 break;
982 case SID_RPT_SPREADSHEET:
983 if (m_xReportDefinition.is() )
984 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII );
985 break;
986 case SID_REPORTHEADER_WITHOUT_UNDO:
987 case SID_REPORTFOOTER_WITHOUT_UNDO:
988 case SID_REPORTHEADERFOOTER:
989 switchReportSection(_nId);
990 break;
991 case SID_PAGEHEADER_WITHOUT_UNDO:
992 case SID_PAGEFOOTER_WITHOUT_UNDO:
993 case SID_PAGEHEADERFOOTER:
994 switchPageSection(_nId);
995 break;
996 case SID_GROUP_APPEND:
997 case SID_GROUP_REMOVE:
998 modifyGroup(_nId == SID_GROUP_APPEND,aArgs);
999 break;
1000 case SID_GROUPHEADER_WITHOUT_UNDO:
1001 case SID_GROUPHEADER:
1002 createGroupSection(SID_GROUPHEADER == _nId,true,aArgs);
1003 break;
1004 case SID_GROUPFOOTER_WITHOUT_UNDO:
1005 case SID_GROUPFOOTER:
1006 createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs);
1007 break;
1008 case SID_ADD_CONTROL_PAIR:
1009 addPairControls(aArgs);
1010 break;
1011 case SID_REDO:
1012 case SID_UNDO:
1014 const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() );
1015 bool ( SfxUndoManager::*doXDo )() =
1016 ( _nId == SID_UNDO ) ? &SfxUndoManager::Undo : &SfxUndoManager::Redo;
1018 SfxUndoManager& rUndoManager( getUndoManager() );
1019 (rUndoManager.*doXDo)();
1020 InvalidateAll();
1021 if ( m_pGroupsFloater && m_pGroupsFloater->IsVisible() )
1022 m_pGroupsFloater->UpdateData();
1024 break;
1025 case SID_CUT:
1026 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Cut));
1027 break;
1028 case SID_COPY:
1029 getDesignView()->Copy();
1030 break;
1031 case SID_PASTE:
1032 executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fn(&ODesignView::Paste));
1033 break;
1035 case SID_FRAME_TO_TOP:
1036 case SID_FRAME_DOWN:
1037 case SID_FRAME_UP:
1038 case SID_FRAME_TO_BOTTOM:
1039 case SID_OBJECT_HEAVEN:
1040 case SID_OBJECT_HELL:
1041 changeZOrder(_nId);
1042 break;
1043 case SID_DISTRIBUTION:
1045 OSectionView* pSectionView = getCurrentSectionView();
1046 if ( pSectionView )
1047 pSectionView->DistributeMarkedObjects(getFrameWeld());
1049 break;
1050 case SID_OBJECT_SMALLESTWIDTH:
1051 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST);
1052 break;
1053 case SID_OBJECT_SMALLESTHEIGHT:
1054 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST);
1055 break;
1056 case SID_OBJECT_GREATESTWIDTH:
1057 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST);
1058 break;
1059 case SID_OBJECT_GREATESTHEIGHT:
1060 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST);
1061 break;
1062 case SID_SECTION_ALIGN_LEFT:
1063 case SID_OBJECT_ALIGN_LEFT:
1064 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId);
1065 break;
1066 case SID_SECTION_ALIGN_CENTER:
1067 case SID_OBJECT_ALIGN_CENTER:
1068 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId);
1069 break;
1070 case SID_SECTION_ALIGN_RIGHT:
1071 case SID_OBJECT_ALIGN_RIGHT:
1072 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId);
1073 break;
1074 case SID_SECTION_ALIGN_UP:
1075 case SID_OBJECT_ALIGN_UP:
1076 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId);
1077 break;
1078 case SID_SECTION_ALIGN_MIDDLE:
1079 case SID_OBJECT_ALIGN_MIDDLE:
1080 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId);
1081 break;
1082 case SID_SECTION_ALIGN_DOWN:
1083 case SID_OBJECT_ALIGN_DOWN:
1084 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId);
1085 break;
1087 case SID_SECTION_SHRINK_BOTTOM:
1088 case SID_SECTION_SHRINK_TOP:
1089 case SID_SECTION_SHRINK:
1091 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
1092 shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId);
1094 break;
1096 case SID_SELECTALL:
1097 getDesignView()->SelectAll(OBJ_NONE);
1098 break;
1099 case SID_SELECTALL_IN_SECTION:
1101 OSectionView* pSectionView = getCurrentSectionView();
1102 if ( pSectionView )
1103 pSectionView->MarkAll();
1105 break;
1106 case SID_ESCAPE:
1107 getDesignView()->SetMode(DlgEdMode::Select);
1108 InvalidateFeature( SID_OBJECT_SELECT );
1109 break;
1110 case SID_SELECT_ALL_EDITS:
1111 getDesignView()->SelectAll(OBJ_DLG_FORMATTEDFIELD);
1112 break;
1113 case SID_SELECT_ALL_LABELS:
1114 getDesignView()->SelectAll(OBJ_DLG_FIXEDTEXT);
1115 break;
1116 case SID_TERMINATE_INPLACEACTIVATION:
1118 OSectionWindow* pSection = getDesignView()->getMarkedSection();
1119 if ( pSection )
1120 pSection->getReportSection().deactivateOle();
1122 break;
1123 case SID_SELECT:
1124 if ( aArgs.getLength() == 1 )
1125 select(aArgs[0].Value);
1126 break;
1127 case SID_SELECT_REPORT:
1128 select(uno::makeAny(m_xReportDefinition));
1129 break;
1130 case SID_EXECUTE_REPORT:
1131 getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport));
1132 break;
1133 case SID_RPT_NEW_FUNCTION:
1134 createNewFunction(aArgs[0].Value);
1135 break;
1136 case SID_COLLAPSE_SECTION:
1137 collapseSection(true);
1138 break;
1139 case SID_EXPAND_SECTION:
1140 collapseSection(false);
1141 break;
1142 case SID_NEXT_MARK:
1143 markSection(true);
1144 break;
1145 case SID_PREV_MARK:
1146 markSection(false);
1147 break;
1148 case SID_DELETE:
1149 if ( aArgs.getLength() == 1 )
1151 uno::Reference< report::XFunction> xFunction;
1152 aArgs[0].Value >>= xFunction;
1153 if ( xFunction.is() )
1155 uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW);
1156 sal_Int32 nIndex = getPositionInIndexAccess(xFunctions.get(),xFunction);
1157 const OUString sUndoAction = RptResId(RID_STR_UNDO_REMOVE_FUNCTION);
1158 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1159 xFunctions->removeByIndex(nIndex);
1160 select(uno::makeAny(xFunctions->getParent()));
1161 InvalidateFeature( SID_UNDO );
1164 else
1165 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Delete));
1166 break;
1167 case SID_GRID_USE:
1168 getDesignView()->setGridSnap(m_bGridUse = !m_bGridUse);
1169 break;
1170 case SID_HELPLINES_MOVE:
1171 getDesignView()->setDragStripes(m_bHelplinesMove = !m_bHelplinesMove);
1172 break;
1173 case SID_GRID_VISIBLE:
1174 getDesignView()->toggleGrid(m_bGridVisible = !m_bGridVisible);
1175 break;
1176 case SID_RULER:
1177 getDesignView()->showRuler(m_bShowRuler = !m_bShowRuler);
1178 break;
1179 case SID_OBJECT_SELECT:
1180 getDesignView()->SetMode(DlgEdMode::Select);
1181 InvalidateAll();
1182 break;
1183 case SID_INSERT_DIAGRAM:
1184 getDesignView()->SetMode( DlgEdMode::Insert );
1185 getDesignView()->SetInsertObj( OBJ_OLE2);
1186 createDefaultControl(aArgs);
1187 InvalidateAll();
1188 break;
1189 case SID_FM_FIXEDTEXT:
1190 getDesignView()->SetMode( DlgEdMode::Insert );
1191 getDesignView()->SetInsertObj( OBJ_DLG_FIXEDTEXT );
1192 createDefaultControl(aArgs);
1193 InvalidateAll();
1194 break;
1195 case SID_INSERT_HFIXEDLINE:
1196 getDesignView()->SetMode( DlgEdMode::Insert );
1197 getDesignView()->SetInsertObj( OBJ_DLG_HFIXEDLINE );
1198 createDefaultControl(aArgs);
1199 InvalidateAll();
1200 break;
1201 case SID_INSERT_VFIXEDLINE:
1202 getDesignView()->SetMode( DlgEdMode::Insert );
1203 getDesignView()->SetInsertObj( OBJ_DLG_VFIXEDLINE );
1204 createDefaultControl(aArgs);
1205 InvalidateAll();
1206 break;
1207 case SID_FM_EDIT:
1208 getDesignView()->SetMode( DlgEdMode::Insert );
1209 getDesignView()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
1210 createDefaultControl(aArgs);
1211 InvalidateAll();
1212 break;
1213 case SID_FM_IMAGECONTROL:
1214 getDesignView()->SetMode( DlgEdMode::Insert );
1215 getDesignView()->SetInsertObj( OBJ_DLG_IMAGECONTROL );
1216 createDefaultControl(aArgs);
1217 InvalidateAll();
1218 break;
1219 case SID_DRAWTBX_CS_BASIC:
1220 case SID_DRAWTBX_CS_BASIC1:
1221 case SID_DRAWTBX_CS_BASIC2:
1222 case SID_DRAWTBX_CS_BASIC3:
1223 case SID_DRAWTBX_CS_BASIC4:
1224 case SID_DRAWTBX_CS_BASIC5:
1225 case SID_DRAWTBX_CS_BASIC6:
1226 case SID_DRAWTBX_CS_BASIC7:
1227 case SID_DRAWTBX_CS_BASIC8:
1228 case SID_DRAWTBX_CS_BASIC9:
1229 case SID_DRAWTBX_CS_BASIC10:
1230 case SID_DRAWTBX_CS_BASIC11:
1231 case SID_DRAWTBX_CS_BASIC12:
1232 case SID_DRAWTBX_CS_BASIC13:
1233 case SID_DRAWTBX_CS_BASIC14:
1234 case SID_DRAWTBX_CS_BASIC15:
1235 case SID_DRAWTBX_CS_BASIC16:
1236 case SID_DRAWTBX_CS_BASIC17:
1237 case SID_DRAWTBX_CS_BASIC18:
1238 case SID_DRAWTBX_CS_BASIC19:
1239 case SID_DRAWTBX_CS_BASIC20:
1240 case SID_DRAWTBX_CS_BASIC21:
1241 case SID_DRAWTBX_CS_BASIC22:
1242 case SID_DRAWTBX_CS_SYMBOL1:
1243 case SID_DRAWTBX_CS_SYMBOL2:
1244 case SID_DRAWTBX_CS_SYMBOL3:
1245 case SID_DRAWTBX_CS_SYMBOL4:
1246 case SID_DRAWTBX_CS_SYMBOL5:
1247 case SID_DRAWTBX_CS_SYMBOL6:
1248 case SID_DRAWTBX_CS_SYMBOL7:
1249 case SID_DRAWTBX_CS_SYMBOL8:
1250 case SID_DRAWTBX_CS_SYMBOL9:
1251 case SID_DRAWTBX_CS_SYMBOL10:
1252 case SID_DRAWTBX_CS_SYMBOL11:
1253 case SID_DRAWTBX_CS_SYMBOL12:
1254 case SID_DRAWTBX_CS_SYMBOL13:
1255 case SID_DRAWTBX_CS_SYMBOL14:
1256 case SID_DRAWTBX_CS_SYMBOL15:
1257 case SID_DRAWTBX_CS_SYMBOL16:
1258 case SID_DRAWTBX_CS_SYMBOL17:
1259 case SID_DRAWTBX_CS_SYMBOL18:
1260 case SID_DRAWTBX_CS_ARROW1:
1261 case SID_DRAWTBX_CS_ARROW2:
1262 case SID_DRAWTBX_CS_ARROW3:
1263 case SID_DRAWTBX_CS_ARROW4:
1264 case SID_DRAWTBX_CS_ARROW5:
1265 case SID_DRAWTBX_CS_ARROW6:
1266 case SID_DRAWTBX_CS_ARROW7:
1267 case SID_DRAWTBX_CS_ARROW8:
1268 case SID_DRAWTBX_CS_ARROW9:
1269 case SID_DRAWTBX_CS_ARROW10:
1270 case SID_DRAWTBX_CS_ARROW11:
1271 case SID_DRAWTBX_CS_ARROW12:
1272 case SID_DRAWTBX_CS_ARROW13:
1273 case SID_DRAWTBX_CS_ARROW14:
1274 case SID_DRAWTBX_CS_ARROW15:
1275 case SID_DRAWTBX_CS_ARROW16:
1276 case SID_DRAWTBX_CS_ARROW17:
1277 case SID_DRAWTBX_CS_ARROW18:
1278 case SID_DRAWTBX_CS_ARROW19:
1279 case SID_DRAWTBX_CS_ARROW20:
1280 case SID_DRAWTBX_CS_ARROW21:
1281 case SID_DRAWTBX_CS_ARROW22:
1282 case SID_DRAWTBX_CS_ARROW23:
1283 case SID_DRAWTBX_CS_ARROW24:
1284 case SID_DRAWTBX_CS_ARROW25:
1285 case SID_DRAWTBX_CS_ARROW26:
1286 case SID_DRAWTBX_CS_STAR1:
1287 case SID_DRAWTBX_CS_STAR2:
1288 case SID_DRAWTBX_CS_STAR3:
1289 case SID_DRAWTBX_CS_STAR4:
1290 case SID_DRAWTBX_CS_STAR5:
1291 case SID_DRAWTBX_CS_STAR6:
1292 case SID_DRAWTBX_CS_STAR7:
1293 case SID_DRAWTBX_CS_STAR8:
1294 case SID_DRAWTBX_CS_STAR9:
1295 case SID_DRAWTBX_CS_STAR10:
1296 case SID_DRAWTBX_CS_STAR11:
1297 case SID_DRAWTBX_CS_STAR12:
1298 case SID_DRAWTBX_CS_FLOWCHART1:
1299 case SID_DRAWTBX_CS_FLOWCHART2:
1300 case SID_DRAWTBX_CS_FLOWCHART3:
1301 case SID_DRAWTBX_CS_FLOWCHART4:
1302 case SID_DRAWTBX_CS_FLOWCHART5:
1303 case SID_DRAWTBX_CS_FLOWCHART6:
1304 case SID_DRAWTBX_CS_FLOWCHART7:
1305 case SID_DRAWTBX_CS_FLOWCHART8:
1306 case SID_DRAWTBX_CS_FLOWCHART9:
1307 case SID_DRAWTBX_CS_FLOWCHART10:
1308 case SID_DRAWTBX_CS_FLOWCHART11:
1309 case SID_DRAWTBX_CS_FLOWCHART12:
1310 case SID_DRAWTBX_CS_FLOWCHART13:
1311 case SID_DRAWTBX_CS_FLOWCHART14:
1312 case SID_DRAWTBX_CS_FLOWCHART15:
1313 case SID_DRAWTBX_CS_FLOWCHART16:
1314 case SID_DRAWTBX_CS_FLOWCHART17:
1315 case SID_DRAWTBX_CS_FLOWCHART18:
1316 case SID_DRAWTBX_CS_FLOWCHART19:
1317 case SID_DRAWTBX_CS_FLOWCHART20:
1318 case SID_DRAWTBX_CS_FLOWCHART21:
1319 case SID_DRAWTBX_CS_FLOWCHART22:
1320 case SID_DRAWTBX_CS_FLOWCHART23:
1321 case SID_DRAWTBX_CS_FLOWCHART24:
1322 case SID_DRAWTBX_CS_FLOWCHART25:
1323 case SID_DRAWTBX_CS_FLOWCHART26:
1324 case SID_DRAWTBX_CS_FLOWCHART27:
1325 case SID_DRAWTBX_CS_FLOWCHART28:
1326 case SID_DRAWTBX_CS_CALLOUT1:
1327 case SID_DRAWTBX_CS_CALLOUT2:
1328 case SID_DRAWTBX_CS_CALLOUT3:
1329 case SID_DRAWTBX_CS_CALLOUT4:
1330 case SID_DRAWTBX_CS_CALLOUT5:
1331 case SID_DRAWTBX_CS_CALLOUT6:
1332 case SID_DRAWTBX_CS_CALLOUT7:
1333 case SID_DRAWTBX_CS_SYMBOL:
1334 case SID_DRAWTBX_CS_ARROW:
1335 case SID_DRAWTBX_CS_FLOWCHART:
1336 case SID_DRAWTBX_CS_CALLOUT:
1337 case SID_DRAWTBX_CS_STAR:
1338 getDesignView()->SetMode( DlgEdMode::Insert );
1340 URL aUrl = getURLForId(_nId);
1341 sal_Int32 nIndex = 1;
1342 OUString sType = aUrl.Complete.getToken(0,'.',nIndex);
1343 if ( nIndex == -1 || sType.isEmpty() )
1345 switch(_nId)
1347 case SID_DRAWTBX_CS_SYMBOL:
1348 sType = "smiley";
1349 break;
1350 case SID_DRAWTBX_CS_ARROW:
1351 sType = "left-right-arrow";
1352 break;
1353 case SID_DRAWTBX_CS_FLOWCHART:
1354 sType = "flowchart-internal-storage";
1355 break;
1356 case SID_DRAWTBX_CS_CALLOUT:
1357 sType = "round-rectangular-callout";
1358 break;
1359 case SID_DRAWTBX_CS_STAR:
1360 sType = "star5";
1361 break;
1362 default:
1363 sType = "diamond";
1366 else
1367 sType = aUrl.Complete.getToken(0,'.',nIndex);
1369 getDesignView()->SetInsertObj( OBJ_CUSTOMSHAPE ,sType);
1370 createDefaultControl(aArgs);
1372 InvalidateAll();
1373 break;
1374 case SID_RPT_SHOWREPORTEXPLORER:
1375 if ( isUiVisible() )
1376 getDesignView()->toggleReportExplorer();
1377 break;
1378 case SID_FM_ADD_FIELD:
1379 if ( isUiVisible() )
1380 getDesignView()->toggleAddField();
1381 break;
1382 case SID_SHOW_PROPERTYBROWSER:
1383 if ( m_bShowProperties )
1384 m_sLastActivePage = getDesignView()->getCurrentPage();
1385 else
1386 getDesignView()->setCurrentPage(m_sLastActivePage);
1388 if ( isUiVisible() )
1390 m_bShowProperties = !m_bShowProperties;
1391 if ( aArgs.getLength() == 1 )
1392 aArgs[0].Value >>= m_bShowProperties;
1394 getDesignView()->togglePropertyBrowser(m_bShowProperties);
1396 break;
1397 case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do
1398 m_sLastActivePage = getDesignView()->getCurrentPage();
1399 break;
1400 case SID_SPLIT_POSITION:
1401 getDesignView()->Resize();
1402 break;
1403 case SID_PAGEDIALOG:
1404 case SID_ATTR_CHAR_COLOR_BACKGROUND:
1406 uno::Reference<report::XSection> xSection;
1407 if (aArgs.getLength() == 1 )
1408 aArgs[0].Value >>= xSection;
1409 else if (_nId == SID_ATTR_CHAR_COLOR_BACKGROUND)
1410 xSection.set(getDesignView()->getMarkedSection()->getReportSection().getSection());
1411 openPageDialog(xSection);
1412 bForceBroadcast = true;
1414 break;
1415 case SID_SORTINGANDGROUPING:
1416 openSortingAndGroupingDialog();
1417 break;
1418 case SID_BACKGROUND_COLOR:
1420 const util::Color aColor( lcl_extractBackgroundColor( aArgs ) );
1421 if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) )
1423 uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
1424 if ( xSection.is() )
1426 xSection->setBackColor( aColor );
1429 bForceBroadcast = true;
1431 break;
1432 case SID_ATTR_CHAR_WEIGHT:
1433 case SID_ATTR_CHAR_POSTURE:
1434 case SID_ATTR_CHAR_UNDERLINE:
1436 uno::Reference< awt::XWindow> xWindow;
1437 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1438 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1440 const OUString sUndoAction(RptResId(RID_STR_UNDO_CHANGEFONT));
1441 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1443 for (const auto& rxControlFormat : aControlsFormats)
1445 uno::Reference< report::XReportControlFormat> xReportControlFormat(rxControlFormat,uno::UNO_QUERY);
1446 lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
1449 break;
1450 case SID_ATTR_CHAR_COLOR:
1451 case SID_ATTR_CHAR_COLOR2:
1452 case SID_ATTR_CHAR_COLOR_EXT:
1454 const SequenceAsHashMap aMap(aArgs);
1455 const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color());
1456 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs);
1457 bForceBroadcast = true;
1459 break;
1460 case SID_ATTR_CHAR_FONT:
1461 if ( aArgs.getLength() == 1 )
1463 awt::FontDescriptor aFont;
1464 if ( aArgs[0].Value >>= aFont )
1466 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs);
1469 break;
1470 case SID_ATTR_CHAR_FONTHEIGHT:
1471 if ( aArgs.getLength() == 1 )
1473 float fSelVal = 0.0;
1474 if ( aArgs[0].Value >>= fSelVal )
1475 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs);
1477 break;
1478 case SID_ATTR_PARA_ADJUST_LEFT:
1479 case SID_ATTR_PARA_ADJUST_CENTER:
1480 case SID_ATTR_PARA_ADJUST_RIGHT:
1481 case SID_ATTR_PARA_ADJUST_BLOCK:
1483 style::ParagraphAdjust eParagraphAdjust = style::ParagraphAdjust_LEFT;
1484 switch(_nId)
1486 case SID_ATTR_PARA_ADJUST_LEFT:
1487 eParagraphAdjust = style::ParagraphAdjust_LEFT;
1488 break;
1489 case SID_ATTR_PARA_ADJUST_CENTER:
1490 eParagraphAdjust = style::ParagraphAdjust_CENTER;
1491 break;
1492 case SID_ATTR_PARA_ADJUST_RIGHT:
1493 eParagraphAdjust = style::ParagraphAdjust_RIGHT;
1494 break;
1495 case SID_ATTR_PARA_ADJUST_BLOCK:
1496 eParagraphAdjust = style::ParagraphAdjust_BLOCK;
1497 break;
1499 impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(static_cast<sal_Int16>(eParagraphAdjust)),aArgs);
1501 InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT);
1502 InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER);
1503 InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT);
1504 InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK);
1506 break;
1507 case SID_CHAR_DLG:
1509 uno::Sequence< beans::NamedValue > aSettings;
1510 uno::Reference< awt::XWindow> xWindow;
1511 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1512 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1514 if ( !aControlsFormats.empty() )
1516 const OUString sUndoAction( RptResId( RID_STR_UNDO_CHANGEFONT ) );
1517 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1519 for (const auto& rxControlFormat : aControlsFormats)
1521 uno::Reference< report::XReportControlFormat > xFormat( rxControlFormat, uno::UNO_QUERY );
1522 if ( !xFormat.is() )
1523 continue;
1525 if ( !aSettings.hasElements() )
1527 ::rptui::openCharDialog( xFormat, xWindow, aSettings );
1528 if ( !aSettings.hasElements() )
1529 break;
1532 applyCharacterSettings( xFormat, aSettings );
1535 InvalidateAll();
1538 break;
1539 case SID_INSERT_GRAPHIC:
1540 insertGraphic();
1541 break;
1542 case SID_SETCONTROLDEFAULTS:
1543 break;
1544 case SID_CONDITIONALFORMATTING:
1546 uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
1547 if ( xFormattedField.is() )
1549 ScopedVclPtrInstance< ConditionalFormattingDialog > aDlg( getView(), xFormattedField.get(), *this );
1550 aDlg->Execute();
1553 break;
1554 case SID_DATETIME:
1555 if ( m_xReportDefinition.is() )
1557 if ( !aArgs.hasElements() )
1559 ODateTimeDialog aDlg(getFrameWeld(), getDesignView()->getCurrentSection(), this);
1560 aDlg.run();
1562 else
1563 createDateTime(aArgs);
1565 break;
1566 case SID_INSERT_FLD_PGNUMBER:
1567 if ( m_xReportDefinition.is() )
1569 if ( !aArgs.hasElements() )
1571 OPageNumberDialog aDlg(getFrameWeld(), m_xReportDefinition, this);
1572 aDlg.run();
1574 else
1575 createPageNumber(aArgs);
1577 break;
1578 case SID_EXPORTDOC:
1579 case SID_EXPORTDOCASPDF:
1580 case SID_PRINTPREVIEW:
1581 break;
1582 case SID_EDITDOC:
1583 if(isEditable())
1584 { // the state should be changed to not editable
1585 setModified(false); // and we are not modified yet
1587 setEditable(!isEditable());
1588 InvalidateAll();
1589 return;
1590 case SID_GROUP:
1591 break;
1592 case SID_ATTR_ZOOM:
1593 if ( !aArgs.hasElements() )
1595 openZoomDialog();
1597 else if ( aArgs.getLength() == 1 && aArgs[0].Name == "Zoom" )
1599 SvxZoomItem aZoomItem;
1600 aZoomItem.PutValue(aArgs[0].Value, 0);
1601 m_nZoomValue = aZoomItem.GetValue();
1602 m_eZoomType = aZoomItem.GetType();
1603 impl_zoom_nothrow();
1605 break;
1606 case SID_ATTR_ZOOMSLIDER:
1607 if ( aArgs.getLength() == 1 && aArgs[0].Name == "ZoomSlider" )
1609 SvxZoomSliderItem aZoomSlider;
1610 aZoomSlider.PutValue(aArgs[0].Value, 0);
1611 m_nZoomValue = aZoomSlider.GetValue();
1612 m_eZoomType = SvxZoomType::PERCENT;
1613 impl_zoom_nothrow();
1615 break;
1616 default:
1617 OReportController_BASE::Execute(_nId,aArgs);
1619 InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast);
1622 void OReportController::impl_initialize( )
1624 OReportController_BASE::impl_initialize();
1626 const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
1628 rArguments.get_ensureType( PROPERTY_REPORTNAME, m_sName );
1629 if ( m_sName.isEmpty() )
1630 rArguments.get_ensureType( "DocumentTitle", m_sName );
1634 if ( m_xReportDefinition.is() )
1636 getView()->initialize(); // show the windows and fill with our information
1638 m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
1639 if ( !m_aReportModel )
1640 throw RuntimeException();
1641 m_aReportModel->attachController( *this );
1643 clearUndoManager();
1644 UndoSuppressor aSuppressUndo( getUndoManager() );
1646 ::comphelper::NamedValueCollection aArgs(getModel()->getArgs());
1647 setMode(aArgs.getOrDefault("Mode", OUString("normal")));
1649 listen(true);
1650 setEditable( !m_aReportModel->IsReadOnly() );
1651 m_xFormatter.set(util::NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
1652 m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY));
1654 utl::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() );
1655 OUString sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString());
1657 if ( sHierarchicalDocumentName.isEmpty() && getConnection().is() )
1659 uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW);
1660 uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables();
1661 const uno::Sequence< OUString > aNames( xTables->getElementNames() );
1663 if ( aNames.hasElements() )
1665 m_xReportDefinition->setCommand(aNames[0]);
1666 m_xReportDefinition->setCommandType(sdb::CommandType::TABLE);
1670 m_aVisualAreaSize = m_xReportDefinition->getVisualAreaSize(0);
1674 // check if chart is supported by the engine
1675 checkChartEnabled();
1676 // restore the view data
1677 getDesignView()->toggleGrid(m_bGridVisible);
1678 getDesignView()->showRuler(m_bShowRuler);
1679 getDesignView()->togglePropertyBrowser(m_bShowProperties);
1680 getDesignView()->setCurrentPage(m_sLastActivePage);
1681 getDesignView()->unmarkAllObjects();
1683 if ( m_nPageNum != -1 )
1685 if ( m_nPageNum < m_aReportModel->GetPageCount() )
1687 const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum)));
1688 if ( pPage )
1690 uno::Sequence< beans::PropertyValue> aArgs(1);
1691 aArgs[0].Value <<= pPage->getSection();
1692 executeUnChecked(SID_SELECT,aArgs);
1695 else
1696 m_nPageNum = -1;
1698 getDesignView()->collapseSections(m_aCollapsedSections);
1699 impl_zoom_nothrow();
1700 getDesignView()->Resize();
1701 getDesignView()->Invalidate();
1702 InvalidateAll();
1704 if ( m_bShowProperties && m_nPageNum == -1 )
1706 m_sLastActivePage = "Data";
1707 getDesignView()->setCurrentPage(m_sLastActivePage);
1708 uno::Sequence< beans::PropertyValue> aArgs;
1709 executeUnChecked(SID_SELECT_REPORT,aArgs);
1712 setModified(false); // and we are not modified yet
1714 catch(const SQLException&)
1716 DBG_UNHANDLED_EXCEPTION("reportdesign");
1720 IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow& ,_rAddFieldDlg, void)
1722 WaitObject aObj( getDesignView() );
1723 uno::Sequence< beans::PropertyValue > aArgs = _rAddFieldDlg.getSelectedFieldDescriptors();
1724 // we use this way to create undo actions
1725 if ( aArgs.hasElements() )
1727 executeChecked(SID_ADD_CONTROL_PAIR,aArgs);
1731 bool OReportController::Construct(vcl::Window* pParent)
1733 VclPtrInstance<ODesignView> pMyOwnView( pParent, m_xContext, *this );
1734 StartListening( *pMyOwnView );
1735 setView( pMyOwnView );
1737 // now that we have a view we can create the clipboard listener
1738 m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
1739 m_aSystemClipboard.StartClipboardListening( );
1740 m_pClipboardNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) );
1741 m_pClipboardNotifier->AddListener( getView() );
1743 OReportController_BASE::Construct(pParent);
1744 return true;
1747 sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/)
1749 if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
1750 return true;
1752 SolarMutexGuard aSolarGuard;
1753 ::osl::MutexGuard aGuard( getMutex() );
1755 if ( getView() && getView()->IsInModalMode() )
1756 return false;
1758 // this suspend will be handled in the DBAccess interceptor implementation
1759 return true;
1762 void OReportController::describeSupportedFeatures()
1764 DBSubComponentController::describeSupportedFeatures();
1766 implDescribeSupportedFeature( ".uno:TextDocument", SID_RPT_TEXTDOCUMENT, CommandGroup::APPLICATION );
1767 implDescribeSupportedFeature( ".uno:Spreadsheet", SID_RPT_SPREADSHEET, CommandGroup::APPLICATION );
1769 implDescribeSupportedFeature( ".uno:Redo", SID_REDO, CommandGroup::EDIT );
1770 implDescribeSupportedFeature( ".uno:Undo", SID_UNDO, CommandGroup::EDIT );
1771 implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
1772 implDescribeSupportedFeature( ".uno:SelectAllInSection", SID_SELECTALL_IN_SECTION, CommandGroup::EDIT );
1773 implDescribeSupportedFeature( ".uno:Delete", SID_DELETE, CommandGroup::EDIT );
1774 implDescribeSupportedFeature( ".uno:SelectReport", SID_SELECT_REPORT, CommandGroup::EDIT );
1775 implDescribeSupportedFeature( ".uno:ExecuteReport", SID_EXECUTE_REPORT, CommandGroup::EDIT );
1777 implDescribeSupportedFeature( ".uno:GridVisible", SID_GRID_VISIBLE, CommandGroup::VIEW );
1778 implDescribeSupportedFeature( ".uno:GridUse", SID_GRID_USE, CommandGroup::VIEW );
1779 implDescribeSupportedFeature( ".uno:HelplinesMove", SID_HELPLINES_MOVE, CommandGroup::VIEW );
1780 implDescribeSupportedFeature( ".uno:ShowRuler", SID_RULER, CommandGroup::VIEW );
1781 implDescribeSupportedFeature( ".uno:AddField", SID_FM_ADD_FIELD, CommandGroup::VIEW );
1782 implDescribeSupportedFeature( ".uno:ReportNavigator", SID_RPT_SHOWREPORTEXPLORER, CommandGroup::VIEW );
1783 implDescribeSupportedFeature( ".uno:ControlProperties", SID_SHOW_PROPERTYBROWSER, CommandGroup::VIEW );
1784 implDescribeSupportedFeature( ".uno:DbSortingAndGrouping", SID_SORTINGANDGROUPING, CommandGroup::VIEW );
1785 implDescribeSupportedFeature( ".uno:PageHeaderFooter", SID_PAGEHEADERFOOTER, CommandGroup::VIEW );
1786 implDescribeSupportedFeature( ".uno:ReportHeaderFooter", SID_REPORTHEADERFOOTER, CommandGroup::VIEW );
1787 implDescribeSupportedFeature( ".uno:ZoomSlider", SID_ATTR_ZOOMSLIDER, CommandGroup::VIEW );
1788 implDescribeSupportedFeature( ".uno:Zoom", SID_ATTR_ZOOM, CommandGroup::VIEW );
1790 implDescribeSupportedFeature( ".uno:ConditionalFormatting", SID_CONDITIONALFORMATTING, CommandGroup::FORMAT );
1791 implDescribeSupportedFeature( ".uno:PageDialog", SID_PAGEDIALOG, CommandGroup::FORMAT );
1792 implDescribeSupportedFeature( ".uno:ResetAttributes", SID_SETCONTROLDEFAULTS, CommandGroup::FORMAT );
1794 implDescribeSupportedFeature( ".uno:Bold", SID_ATTR_CHAR_WEIGHT, CommandGroup::FORMAT );
1795 implDescribeSupportedFeature( ".uno:Italic", SID_ATTR_CHAR_POSTURE, CommandGroup::FORMAT );
1796 implDescribeSupportedFeature( ".uno:Underline", SID_ATTR_CHAR_UNDERLINE, CommandGroup::FORMAT );
1797 implDescribeSupportedFeature( ".uno:BackColor", SID_ATTR_CHAR_COLOR_BACKGROUND, CommandGroup::FORMAT );
1798 implDescribeSupportedFeature( ".uno:BackgroundColor", SID_BACKGROUND_COLOR, CommandGroup::FORMAT );
1799 implDescribeSupportedFeature( ".uno:CharColorExt", SID_ATTR_CHAR_COLOR_EXT);
1800 implDescribeSupportedFeature( ".uno:Color", SID_ATTR_CHAR_COLOR);
1801 implDescribeSupportedFeature( ".uno:FontColor", SID_ATTR_CHAR_COLOR2, CommandGroup::FORMAT );
1802 implDescribeSupportedFeature( ".uno:FontDialog", SID_CHAR_DLG, CommandGroup::FORMAT );
1803 implDescribeSupportedFeature( ".uno:LeftPara", SID_ATTR_PARA_ADJUST_LEFT, CommandGroup::FORMAT );
1804 implDescribeSupportedFeature( ".uno:CenterPara", SID_ATTR_PARA_ADJUST_CENTER, CommandGroup::FORMAT );
1805 implDescribeSupportedFeature( ".uno:RightPara", SID_ATTR_PARA_ADJUST_RIGHT, CommandGroup::FORMAT );
1806 implDescribeSupportedFeature( ".uno:JustifyPara", SID_ATTR_PARA_ADJUST_BLOCK, CommandGroup::FORMAT );
1808 implDescribeSupportedFeature( ".uno:FontHeight", SID_ATTR_CHAR_FONTHEIGHT, CommandGroup::FORMAT );
1809 implDescribeSupportedFeature( ".uno:CharFontName", SID_ATTR_CHAR_FONT, CommandGroup::FORMAT );
1811 implDescribeSupportedFeature( ".uno:ArrangeMenu", SID_ARRANGEMENU, CommandGroup::FORMAT );
1812 implDescribeSupportedFeature( ".uno:BringToFront", SID_FRAME_TO_TOP, CommandGroup::FORMAT );
1813 implDescribeSupportedFeature( ".uno:ObjectBackOne", SID_FRAME_DOWN, CommandGroup::FORMAT );
1814 implDescribeSupportedFeature( ".uno:ObjectForwardOne", SID_FRAME_UP, CommandGroup::FORMAT );
1815 implDescribeSupportedFeature( ".uno:SendToBack", SID_FRAME_TO_BOTTOM, CommandGroup::FORMAT );
1816 implDescribeSupportedFeature( ".uno:SetObjectToForeground", SID_OBJECT_HEAVEN, CommandGroup::FORMAT );
1817 implDescribeSupportedFeature( ".uno:SetObjectToBackground", SID_OBJECT_HELL, CommandGroup::FORMAT );
1819 implDescribeSupportedFeature( ".uno:ObjectAlign", SID_OBJECT_ALIGN, CommandGroup::FORMAT );
1820 implDescribeSupportedFeature( ".uno:ObjectAlignLeft", SID_OBJECT_ALIGN_LEFT, CommandGroup::FORMAT );
1821 implDescribeSupportedFeature( ".uno:AlignCenter", SID_OBJECT_ALIGN_CENTER, CommandGroup::FORMAT );
1822 implDescribeSupportedFeature( ".uno:ObjectAlignRight", SID_OBJECT_ALIGN_RIGHT, CommandGroup::FORMAT );
1823 implDescribeSupportedFeature( ".uno:AlignUp", SID_OBJECT_ALIGN_UP, CommandGroup::FORMAT );
1824 implDescribeSupportedFeature( ".uno:AlignMiddle", SID_OBJECT_ALIGN_MIDDLE, CommandGroup::FORMAT );
1825 implDescribeSupportedFeature( ".uno:AlignDown", SID_OBJECT_ALIGN_DOWN, CommandGroup::FORMAT );
1827 implDescribeSupportedFeature( ".uno:SectionAlign", SID_SECTION_ALIGN, CommandGroup::FORMAT );
1828 implDescribeSupportedFeature( ".uno:SectionAlignLeft", SID_SECTION_ALIGN_LEFT, CommandGroup::FORMAT );
1829 implDescribeSupportedFeature( ".uno:SectionAlignCenter", SID_SECTION_ALIGN_CENTER, CommandGroup::FORMAT );
1830 implDescribeSupportedFeature( ".uno:SectionAlignRight", SID_SECTION_ALIGN_RIGHT, CommandGroup::FORMAT );
1831 implDescribeSupportedFeature( ".uno:SectionAlignTop", SID_SECTION_ALIGN_UP, CommandGroup::FORMAT );
1832 implDescribeSupportedFeature( ".uno:SectionAlignMiddle", SID_SECTION_ALIGN_MIDDLE, CommandGroup::FORMAT );
1833 implDescribeSupportedFeature( ".uno:SectionAlignBottom", SID_SECTION_ALIGN_DOWN, CommandGroup::FORMAT );
1834 implDescribeSupportedFeature( ".uno:SectionShrink", SID_SECTION_SHRINK, CommandGroup::FORMAT );
1835 implDescribeSupportedFeature( ".uno:SectionShrinkTop", SID_SECTION_SHRINK_TOP, CommandGroup::FORMAT );
1836 implDescribeSupportedFeature( ".uno:SectionShrinkBottom", SID_SECTION_SHRINK_BOTTOM, CommandGroup::FORMAT );
1838 implDescribeSupportedFeature( ".uno:ObjectResize", SID_OBJECT_RESIZING, CommandGroup::FORMAT );
1839 implDescribeSupportedFeature( ".uno:SmallestWidth", SID_OBJECT_SMALLESTWIDTH, CommandGroup::FORMAT );
1840 implDescribeSupportedFeature( ".uno:SmallestHeight", SID_OBJECT_SMALLESTHEIGHT, CommandGroup::FORMAT );
1841 implDescribeSupportedFeature( ".uno:GreatestWidth", SID_OBJECT_GREATESTWIDTH, CommandGroup::FORMAT );
1842 implDescribeSupportedFeature( ".uno:GreatestHeight", SID_OBJECT_GREATESTHEIGHT, CommandGroup::FORMAT );
1843 implDescribeSupportedFeature( ".uno:Distribution", SID_DISTRIBUTION, CommandGroup::FORMAT );
1845 implDescribeSupportedFeature( ".uno:ExportTo", SID_EXPORTDOC, CommandGroup::APPLICATION );
1846 implDescribeSupportedFeature( ".uno:ExportToPDF", SID_EXPORTDOCASPDF, CommandGroup::APPLICATION );
1847 implDescribeSupportedFeature( ".uno:PrintPreview", SID_PRINTPREVIEW, CommandGroup::APPLICATION );
1849 implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
1850 implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT );
1851 implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT );
1852 implDescribeSupportedFeature( ".uno:SaveACopy", SID_SAVEACOPY, CommandGroup::DOCUMENT );
1854 implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT );
1855 implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT );
1856 implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT );
1857 implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT );
1858 // controls
1859 implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT );
1860 implDescribeSupportedFeature( ".uno:Label", SID_FM_FIXEDTEXT, CommandGroup::INSERT );
1861 implDescribeSupportedFeature( ".uno:Edit", SID_FM_EDIT, CommandGroup::INSERT );
1862 implDescribeSupportedFeature( ".uno:ImageControl", SID_FM_IMAGECONTROL, CommandGroup::INSERT );
1863 implDescribeSupportedFeature( ".uno:HFixedLine", SID_INSERT_HFIXEDLINE, CommandGroup::INSERT );
1864 implDescribeSupportedFeature( ".uno:VFixedLine", SID_INSERT_VFIXEDLINE, CommandGroup::INSERT );
1866 // shapes
1867 implDescribeSupportedFeature( ".uno:BasicShapes", SID_DRAWTBX_CS_BASIC, CommandGroup::INSERT );
1868 implDescribeSupportedFeature( ".uno:BasicShapes.rectangle", SID_DRAWTBX_CS_BASIC1, CommandGroup::INSERT );
1869 implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2, CommandGroup::INSERT );
1870 implDescribeSupportedFeature( ".uno:BasicShapes.quadrat", SID_DRAWTBX_CS_BASIC3, CommandGroup::INSERT );
1871 implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4, CommandGroup::INSERT );
1872 implDescribeSupportedFeature( ".uno:BasicShapes.circle", SID_DRAWTBX_CS_BASIC5, CommandGroup::INSERT );
1873 implDescribeSupportedFeature( ".uno:BasicShapes.ellipse", SID_DRAWTBX_CS_BASIC6, CommandGroup::INSERT );
1874 implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie", SID_DRAWTBX_CS_BASIC7, CommandGroup::INSERT );
1875 implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8, CommandGroup::INSERT );
1876 implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9, CommandGroup::INSERT );
1877 implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid", SID_DRAWTBX_CS_BASIC10, CommandGroup::INSERT );
1878 implDescribeSupportedFeature( ".uno:BasicShapes.diamond", SID_DRAWTBX_CS_BASIC11, CommandGroup::INSERT );
1879 implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12, CommandGroup::INSERT );
1880 implDescribeSupportedFeature( ".uno:BasicShapes.pentagon", SID_DRAWTBX_CS_BASIC13, CommandGroup::INSERT );
1881 implDescribeSupportedFeature( ".uno:BasicShapes.hexagon", SID_DRAWTBX_CS_BASIC14, CommandGroup::INSERT );
1882 implDescribeSupportedFeature( ".uno:BasicShapes.octagon", SID_DRAWTBX_CS_BASIC15, CommandGroup::INSERT );
1883 implDescribeSupportedFeature( ".uno:BasicShapes.cross", SID_DRAWTBX_CS_BASIC16, CommandGroup::INSERT );
1884 implDescribeSupportedFeature( ".uno:BasicShapes.ring", SID_DRAWTBX_CS_BASIC17, CommandGroup::INSERT );
1885 implDescribeSupportedFeature( ".uno:BasicShapes.block-arc", SID_DRAWTBX_CS_BASIC18, CommandGroup::INSERT );
1886 implDescribeSupportedFeature( ".uno:BasicShapes.can", SID_DRAWTBX_CS_BASIC19, CommandGroup::INSERT );
1887 implDescribeSupportedFeature( ".uno:BasicShapes.cube", SID_DRAWTBX_CS_BASIC20, CommandGroup::INSERT );
1888 implDescribeSupportedFeature( ".uno:BasicShapes.paper", SID_DRAWTBX_CS_BASIC21, CommandGroup::INSERT );
1889 implDescribeSupportedFeature( ".uno:BasicShapes.frame", SID_DRAWTBX_CS_BASIC22, CommandGroup::INSERT );
1891 implDescribeSupportedFeature( ".uno:SymbolShapes", SID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT );
1893 implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" , SID_DRAWTBX_CS_SYMBOL1, CommandGroup::INSERT );
1894 implDescribeSupportedFeature( ".uno:SymbolShapes.sun" , SID_DRAWTBX_CS_SYMBOL2, CommandGroup::INSERT );
1895 implDescribeSupportedFeature( ".uno:SymbolShapes.moon" , SID_DRAWTBX_CS_SYMBOL3, CommandGroup::INSERT );
1896 implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" , SID_DRAWTBX_CS_SYMBOL4, CommandGroup::INSERT );
1897 implDescribeSupportedFeature( ".uno:SymbolShapes.heart" , SID_DRAWTBX_CS_SYMBOL5, CommandGroup::INSERT );
1898 implDescribeSupportedFeature( ".uno:SymbolShapes.flower" , SID_DRAWTBX_CS_SYMBOL6, CommandGroup::INSERT );
1899 implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" , SID_DRAWTBX_CS_SYMBOL7, CommandGroup::INSERT );
1900 implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" , SID_DRAWTBX_CS_SYMBOL8, CommandGroup::INSERT );
1901 implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" , SID_DRAWTBX_CS_SYMBOL9, CommandGroup::INSERT );
1902 implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10, CommandGroup::INSERT );
1903 implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11, CommandGroup::INSERT );
1904 implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12, CommandGroup::INSERT );
1905 implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" , SID_DRAWTBX_CS_SYMBOL13, CommandGroup::INSERT );
1906 implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" , SID_DRAWTBX_CS_SYMBOL14, CommandGroup::INSERT );
1907 implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" , SID_DRAWTBX_CS_SYMBOL15, CommandGroup::INSERT );
1908 implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" , SID_DRAWTBX_CS_SYMBOL16, CommandGroup::INSERT );
1909 implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17, CommandGroup::INSERT );
1910 implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18, CommandGroup::INSERT );
1912 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" , SID_DRAWTBX_CS_ARROW1, CommandGroup::INSERT );
1913 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" , SID_DRAWTBX_CS_ARROW2, CommandGroup::INSERT );
1914 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" , SID_DRAWTBX_CS_ARROW3, CommandGroup::INSERT );
1915 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" , SID_DRAWTBX_CS_ARROW4, CommandGroup::INSERT );
1916 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" , SID_DRAWTBX_CS_ARROW5, CommandGroup::INSERT );
1917 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" , SID_DRAWTBX_CS_ARROW6, CommandGroup::INSERT );
1918 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" , SID_DRAWTBX_CS_ARROW7, CommandGroup::INSERT );
1919 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" , SID_DRAWTBX_CS_ARROW8, CommandGroup::INSERT );
1920 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" , SID_DRAWTBX_CS_ARROW9, CommandGroup::INSERT );
1921 implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" , SID_DRAWTBX_CS_ARROW10, CommandGroup::INSERT );
1922 implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" , SID_DRAWTBX_CS_ARROW11, CommandGroup::INSERT );
1923 implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" , SID_DRAWTBX_CS_ARROW12, CommandGroup::INSERT );
1924 implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" , SID_DRAWTBX_CS_ARROW13, CommandGroup::INSERT );
1925 implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" , SID_DRAWTBX_CS_ARROW14, CommandGroup::INSERT );
1926 implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" , SID_DRAWTBX_CS_ARROW15, CommandGroup::INSERT );
1927 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" , SID_DRAWTBX_CS_ARROW16, CommandGroup::INSERT );
1928 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" , SID_DRAWTBX_CS_ARROW17, CommandGroup::INSERT );
1929 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" , SID_DRAWTBX_CS_ARROW18, CommandGroup::INSERT );
1930 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" , SID_DRAWTBX_CS_ARROW19, CommandGroup::INSERT );
1931 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20, CommandGroup::INSERT );
1932 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21, CommandGroup::INSERT );
1933 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22, CommandGroup::INSERT );
1934 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" , SID_DRAWTBX_CS_ARROW23, CommandGroup::INSERT );
1935 implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" , SID_DRAWTBX_CS_ARROW24, CommandGroup::INSERT );
1936 implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" , SID_DRAWTBX_CS_ARROW25, CommandGroup::INSERT );
1937 implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" , SID_DRAWTBX_CS_ARROW26, CommandGroup::INSERT );
1939 implDescribeSupportedFeature( ".uno:StarShapes.bang" , SID_DRAWTBX_CS_STAR1, CommandGroup::INSERT );
1940 implDescribeSupportedFeature( ".uno:StarShapes.star4" , SID_DRAWTBX_CS_STAR2, CommandGroup::INSERT );
1941 implDescribeSupportedFeature( ".uno:StarShapes.star5" , SID_DRAWTBX_CS_STAR3, CommandGroup::INSERT );
1942 implDescribeSupportedFeature( ".uno:StarShapes.star6" , SID_DRAWTBX_CS_STAR4, CommandGroup::INSERT );
1943 implDescribeSupportedFeature( ".uno:StarShapes.star8" , SID_DRAWTBX_CS_STAR5, CommandGroup::INSERT );
1944 implDescribeSupportedFeature( ".uno:StarShapes.star12" , SID_DRAWTBX_CS_STAR6, CommandGroup::INSERT );
1945 implDescribeSupportedFeature( ".uno:StarShapes.star24" , SID_DRAWTBX_CS_STAR7, CommandGroup::INSERT );
1946 implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" , SID_DRAWTBX_CS_STAR8, CommandGroup::INSERT );
1947 implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" , SID_DRAWTBX_CS_STAR9, CommandGroup::INSERT );
1948 implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" , SID_DRAWTBX_CS_STAR10, CommandGroup::INSERT );
1949 implDescribeSupportedFeature( ".uno:StarShapes.signet" , SID_DRAWTBX_CS_STAR11, CommandGroup::INSERT );
1950 implDescribeSupportedFeature( ".uno:StarShapes.doorplate" , SID_DRAWTBX_CS_STAR12, CommandGroup::INSERT );
1952 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" , SID_DRAWTBX_CS_FLOWCHART1, CommandGroup::INSERT );
1953 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" , SID_DRAWTBX_CS_FLOWCHART2, CommandGroup::INSERT );
1954 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" , SID_DRAWTBX_CS_FLOWCHART3, CommandGroup::INSERT );
1955 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" , SID_DRAWTBX_CS_FLOWCHART4, CommandGroup::INSERT );
1956 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" , SID_DRAWTBX_CS_FLOWCHART5, CommandGroup::INSERT );
1957 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" , SID_DRAWTBX_CS_FLOWCHART6, CommandGroup::INSERT );
1958 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" , SID_DRAWTBX_CS_FLOWCHART7, CommandGroup::INSERT );
1959 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" , SID_DRAWTBX_CS_FLOWCHART8, CommandGroup::INSERT );
1960 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" , SID_DRAWTBX_CS_FLOWCHART9, CommandGroup::INSERT );
1961 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" , SID_DRAWTBX_CS_FLOWCHART10, CommandGroup::INSERT );
1962 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" , SID_DRAWTBX_CS_FLOWCHART11, CommandGroup::INSERT );
1963 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" , SID_DRAWTBX_CS_FLOWCHART12, CommandGroup::INSERT );
1964 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" , SID_DRAWTBX_CS_FLOWCHART13, CommandGroup::INSERT );
1965 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" , SID_DRAWTBX_CS_FLOWCHART14, CommandGroup::INSERT );
1966 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" , SID_DRAWTBX_CS_FLOWCHART15, CommandGroup::INSERT );
1967 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" , SID_DRAWTBX_CS_FLOWCHART16, CommandGroup::INSERT );
1968 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" , SID_DRAWTBX_CS_FLOWCHART17, CommandGroup::INSERT );
1969 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" , SID_DRAWTBX_CS_FLOWCHART18, CommandGroup::INSERT );
1970 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" , SID_DRAWTBX_CS_FLOWCHART19, CommandGroup::INSERT );
1971 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" , SID_DRAWTBX_CS_FLOWCHART20, CommandGroup::INSERT );
1972 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" , SID_DRAWTBX_CS_FLOWCHART21, CommandGroup::INSERT );
1973 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" , SID_DRAWTBX_CS_FLOWCHART22, CommandGroup::INSERT );
1974 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" , SID_DRAWTBX_CS_FLOWCHART23, CommandGroup::INSERT );
1975 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" , SID_DRAWTBX_CS_FLOWCHART24, CommandGroup::INSERT );
1976 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" , SID_DRAWTBX_CS_FLOWCHART25, CommandGroup::INSERT );
1977 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" , SID_DRAWTBX_CS_FLOWCHART26, CommandGroup::INSERT );
1978 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27, CommandGroup::INSERT );
1979 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" , SID_DRAWTBX_CS_FLOWCHART28, CommandGroup::INSERT );
1981 implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" , SID_DRAWTBX_CS_CALLOUT1, CommandGroup::INSERT );
1982 implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" , SID_DRAWTBX_CS_CALLOUT2, CommandGroup::INSERT );
1983 implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" , SID_DRAWTBX_CS_CALLOUT3, CommandGroup::INSERT );
1984 implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" , SID_DRAWTBX_CS_CALLOUT4, CommandGroup::INSERT );
1985 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" , SID_DRAWTBX_CS_CALLOUT5, CommandGroup::INSERT );
1986 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" , SID_DRAWTBX_CS_CALLOUT6, CommandGroup::INSERT );
1987 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" , SID_DRAWTBX_CS_CALLOUT7, CommandGroup::INSERT );
1989 implDescribeSupportedFeature( ".uno:ArrowShapes", SID_DRAWTBX_CS_ARROW, CommandGroup::INSERT );
1991 implDescribeSupportedFeature( ".uno:FlowChartShapes", SID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT );
1992 implDescribeSupportedFeature( ".uno:CalloutShapes", SID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT );
1993 implDescribeSupportedFeature( ".uno:StarShapes", SID_DRAWTBX_CS_STAR, CommandGroup::INSERT );
1996 // keys
1997 implDescribeSupportedFeature( ".uno:Escape", SID_ESCAPE, CommandGroup::CONTROLS);
1999 // internal one
2000 implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO", SID_REPORTHEADER_WITHOUT_UNDO);
2001 implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO", SID_REPORTFOOTER_WITHOUT_UNDO);
2002 implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO", SID_PAGEHEADER_WITHOUT_UNDO);
2003 implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO", SID_PAGEFOOTER_WITHOUT_UNDO);
2004 implDescribeSupportedFeature( ".uno:DBBackgroundColor", SID_ATTR_CHAR_COLOR_BACKGROUND);
2005 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER", SID_GROUPHEADER);
2006 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO", SID_GROUPHEADER_WITHOUT_UNDO);
2007 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER", SID_GROUPFOOTER);
2008 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO", SID_GROUPFOOTER_WITHOUT_UNDO);
2009 implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE", SID_GROUP_REMOVE);
2010 implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND", SID_GROUP_APPEND);
2011 implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR", SID_ADD_CONTROL_PAIR);
2012 implDescribeSupportedFeature( ".uno:SplitPosition", SID_SPLIT_POSITION);
2013 implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage", SID_PROPERTYBROWSER_LAST_PAGE);
2014 implDescribeSupportedFeature( ".uno:Select", SID_SELECT);
2015 implDescribeSupportedFeature( ".uno:InsertFunction", SID_RPT_NEW_FUNCTION);
2016 implDescribeSupportedFeature( ".uno:NextMark", SID_NEXT_MARK);
2017 implDescribeSupportedFeature( ".uno:PrevMark", SID_PREV_MARK);
2018 implDescribeSupportedFeature( ".uno:TerminateInplaceActivation", SID_TERMINATE_INPLACEACTIVATION);
2019 implDescribeSupportedFeature( ".uno:SelectAllLabels", SID_SELECT_ALL_LABELS);
2020 implDescribeSupportedFeature( ".uno:SelectAllEdits", SID_SELECT_ALL_EDITS);
2021 implDescribeSupportedFeature( ".uno:CollapseSection", SID_COLLAPSE_SECTION);
2022 implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION);
2025 void OReportController::impl_onModifyChanged()
2029 if ( m_xReportDefinition.is() )
2030 m_xReportDefinition->setModified( impl_isModified() );
2031 DBSubComponentController::impl_onModifyChanged();
2033 catch(const uno::Exception&)
2035 DBG_UNHANDLED_EXCEPTION("reportdesign");
2039 void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager)
2041 if ( _xLayoutManager.is() )
2043 static const OUStringLiteral s_sMenu[] = {
2044 "private:resource/statusbar/statusbar"
2045 ,"private:resource/toolbar/reportcontrols"
2046 ,"private:resource/toolbar/drawbar"
2047 ,"private:resource/toolbar/Formatting"
2048 ,"private:resource/toolbar/alignmentbar"
2049 ,"private:resource/toolbar/sectionalignmentbar"
2050 ,"private:resource/toolbar/resizebar"
2051 ,"private:resource/toolbar/sectionshrinkbar"
2053 for (const auto & i : s_sMenu)
2055 _xLayoutManager->createElement( i );
2056 _xLayoutManager->requestElement( i );
2061 void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow)
2063 uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY);
2064 if ( xGroup.is() )
2066 SolarMutexGuard aSolarGuard;
2067 ::osl::MutexGuard aGuard( getMutex() );
2068 sal_Int32 nGroupPos = 0;
2069 _rEvent.Accessor >>= nGroupPos;
2071 if ( _bShow )
2073 xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2074 xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2076 else
2078 xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2079 xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2082 if ( xGroup->getHeaderOn() )
2084 groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow);
2085 if (_bShow)
2087 m_pReportControllerObserver->AddSection(xGroup->getHeader());
2089 else
2091 m_pReportControllerObserver->RemoveSection(xGroup->getHeader());
2094 if ( xGroup->getFooterOn() )
2096 groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow);
2097 if (_bShow)
2099 m_pReportControllerObserver->AddSection(xGroup->getFooter());
2101 else
2103 m_pReportControllerObserver->RemoveSection(xGroup->getFooter());
2109 // ::container::XContainerListener
2110 void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent )
2112 notifyGroupSections(_rEvent,true);
2115 void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent )
2117 notifyGroupSections(_rEvent,false);
2120 void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ )
2122 SolarMutexGuard aSolarGuard;
2123 ::osl::MutexGuard aGuard( getMutex() );
2124 OSL_FAIL("Not yet implemented!");
2127 void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt )
2129 SolarMutexGuard aSolarGuard;
2130 ::osl::MutexGuard aGuard( getMutex() );
2133 bool bShow = false;
2134 evt.NewValue >>= bShow;
2135 if ( evt.Source == m_xReportDefinition )
2137 if ( evt.PropertyName == PROPERTY_REPORTHEADERON )
2139 const sal_uInt16 nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0;
2140 if ( bShow )
2142 getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition);
2143 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader());
2145 else
2147 getDesignView()->removeSection(nPosition);
2150 else if ( evt.PropertyName == PROPERTY_REPORTFOOTERON )
2152 sal_uInt16 nPosition = getDesignView()->getSectionCount();
2153 if ( m_xReportDefinition->getPageFooterOn() )
2154 --nPosition;
2155 if ( bShow )
2157 getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition);
2158 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter());
2160 else
2162 getDesignView()->removeSection(nPosition - 1);
2165 else if ( evt.PropertyName == PROPERTY_PAGEHEADERON )
2167 if ( bShow )
2169 getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0);
2170 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader());
2172 else
2174 getDesignView()->removeSection(sal_uInt16(0));
2177 else if ( evt.PropertyName == PROPERTY_PAGEFOOTERON )
2179 if ( bShow )
2181 getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
2182 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter());
2184 else
2186 getDesignView()->removeSection(getDesignView()->getSectionCount() - 1);
2189 else if ( evt.PropertyName == PROPERTY_COMMAND
2190 || evt.PropertyName == PROPERTY_COMMANDTYPE
2191 || evt.PropertyName == PROPERTY_ESCAPEPROCESSING
2192 || evt.PropertyName == PROPERTY_FILTER
2195 m_xColumns.clear();
2196 m_xHoldAlive.clear();
2197 InvalidateFeature(SID_FM_ADD_FIELD);
2198 if ( !getDesignView()->isAddFieldVisible() && isUiVisible() )
2199 getDesignView()->toggleAddField();
2201 /// TODO: check what we need to notify here TitleHelper
2202 /*else if ( evt.PropertyName.equals( PROPERTY_CAPTION ) )
2203 updateTitle();*/
2205 else
2207 uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY);
2208 if ( xGroup.is() )
2210 sal_Int32 nGroupPos = getGroupPosition(xGroup);
2212 groupChange(xGroup,evt.PropertyName,nGroupPos,bShow);
2216 catch(const uno::Exception&)
2218 DBG_UNHANDLED_EXCEPTION("reportdesign");
2223 void SAL_CALL OReportController::disposing( const lang::EventObject& Source )
2225 // simply disambiguate
2226 OReportController_BASE::disposing(Source);
2230 static sal_uInt16 lcl_getNonVisbleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups
2231 ,sal_Int32 _nGroupPos
2232 ,::std::function<bool(OGroupHelper *)> const & _pGroupMemberFunction)
2234 uno::Reference< report::XGroup> xGroup;
2235 sal_uInt16 nNonVisibleGroups = 0;
2236 sal_Int32 nCount = _xGroups->getCount();
2237 for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i)
2239 xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY);
2240 OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF");
2241 OGroupHelper aGroupHelper(xGroup);
2242 if ( !_pGroupMemberFunction(&aGroupHelper) )
2243 ++nNonVisibleGroups;
2245 return nNonVisibleGroups;
2248 void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,const OUString& _sPropName,sal_Int32 _nGroupPos,bool _bShow)
2250 ::std::function<bool(OGroupHelper *)> pMemFun = ::std::mem_fn(&OGroupHelper::getHeaderOn);
2251 ::std::function<uno::Reference<report::XSection>(OGroupHelper *)> pMemFunSection = ::std::mem_fn(&OGroupHelper::getHeader);
2252 OUString sColor(DBGROUPHEADER);
2253 sal_uInt16 nPosition = 0;
2254 bool bHandle = false;
2255 if ( _sPropName == PROPERTY_HEADERON )
2257 nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0);
2258 nPosition += (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2259 bHandle = true;
2261 else if ( _sPropName == PROPERTY_FOOTERON )
2263 pMemFun = ::std::mem_fn(&OGroupHelper::getFooterOn);
2264 pMemFunSection = ::std::mem_fn(&OGroupHelper::getFooter);
2265 nPosition = getDesignView()->getSectionCount();
2267 if ( m_xReportDefinition->getPageFooterOn() )
2268 --nPosition;
2269 if ( m_xReportDefinition->getReportFooterOn() )
2270 --nPosition;
2271 sColor = DBGROUPFOOTER;
2272 nPosition -= (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisbleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2273 if ( !_bShow )
2274 --nPosition;
2275 bHandle = true;
2277 if ( bHandle )
2279 if ( _bShow )
2281 OGroupHelper aGroupHelper(_xGroup);
2282 getDesignView()->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition);
2284 else
2286 getDesignView()->removeSection(nPosition);
2291 IMPL_LINK_NOARG(OReportController, OnClipboardChanged, TransferableDataHelper*, void)
2293 OnInvalidateClipboard();
2296 void OReportController::OnInvalidateClipboard()
2298 InvalidateFeature(SID_CUT);
2299 InvalidateFeature(SID_COPY);
2300 InvalidateFeature(SID_PASTE);
2303 void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection)
2305 if ( !m_xReportDefinition.is() )
2306 return;
2308 // UNO->ItemSet
2309 static SfxItemInfo aItemInfos[] =
2311 { SID_ATTR_LRSPACE, true },
2312 { SID_ATTR_ULSPACE, true },
2313 { SID_ATTR_PAGE, true },
2314 { SID_ATTR_PAGE_SIZE, true },
2315 { SID_ENUM_PAGE_MODE, true },
2316 { SID_PAPER_START, true },
2317 { SID_PAPER_END, true },
2318 { SID_ATTR_BRUSH, true },
2319 { XATTR_FILLSTYLE, true },
2320 { XATTR_FILLCOLOR, true },
2321 { XATTR_FILLGRADIENT, true },
2322 { XATTR_FILLHATCH, true },
2323 { XATTR_FILLBITMAP, true },
2324 { XATTR_FILLTRANSPARENCE, true },
2325 { XATTR_GRADIENTSTEPCOUNT, true },
2326 { XATTR_FILLBMP_TILE, true },
2327 { XATTR_FILLBMP_POS, true },
2328 { XATTR_FILLBMP_SIZEX, true },
2329 { XATTR_FILLBMP_SIZEY, true },
2330 { XATTR_FILLFLOATTRANSPARENCE, true },
2331 { XATTR_SECONDARYFILLCOLOR, true },
2332 { XATTR_FILLBMP_SIZELOG, true },
2333 { XATTR_FILLBMP_TILEOFFSETX, true },
2334 { XATTR_FILLBMP_TILEOFFSETY, true },
2335 { XATTR_FILLBMP_STRETCH, true },
2336 { XATTR_FILLBMP_POSOFFSETX, true },
2337 { XATTR_FILLBMP_POSOFFSETY, true },
2338 { XATTR_FILLBACKGROUND, true },
2339 { SID_ATTR_METRIC, true }
2342 MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
2343 FieldUnit eUserMetric = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH;
2344 static const sal_uInt16 pRanges[] =
2346 RPTUI_ID_LRSPACE, XATTR_FILL_LAST,
2347 SID_ATTR_METRIC,SID_ATTR_METRIC,
2350 SfxItemPool* pPool( new SfxItemPool("ReportPageProperties", RPTUI_ID_LRSPACE, RPTUI_ID_METRIC, aItemInfos ) );
2352 const Graphic aNullGraphic;
2353 const ::Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
2354 const ::Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
2355 const XGradient aNullGrad(COL_BLACK, COL_WHITE);
2356 const XHatch aNullHatch(aNullLineCol);
2358 std::vector<SfxPoolItem*> pDefaults
2360 new SvxLRSpaceItem(RPTUI_ID_LRSPACE),
2361 new SvxULSpaceItem(RPTUI_ID_ULSPACE),
2362 new SvxPageItem(RPTUI_ID_PAGE),
2363 new SvxSizeItem(RPTUI_ID_SIZE),
2364 new SfxAllEnumItem(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD),
2365 new SfxAllEnumItem(RPTUI_ID_START,PAPER_A4),
2366 new SfxAllEnumItem(RPTUI_ID_END,PAPER_E),
2367 new SvxBrushItem(RPTUI_ID_BRUSH),
2368 new XFillStyleItem,
2369 new XFillColorItem("", aNullFillCol),
2370 new XFillGradientItem(aNullGrad),
2371 new XFillHatchItem(aNullHatch),
2372 new XFillBitmapItem(aNullGraphic),
2373 new XFillTransparenceItem,
2374 new XGradientStepCountItem,
2375 new XFillBmpTileItem,
2376 new XFillBmpPosItem,
2377 new XFillBmpSizeXItem,
2378 new XFillBmpSizeYItem,
2379 new XFillFloatTransparenceItem(aNullGrad, false),
2380 new XSecondaryFillColorItem("", aNullFillCol),
2381 new XFillBmpSizeLogItem,
2382 new XFillBmpTileOffsetXItem,
2383 new XFillBmpTileOffsetYItem,
2384 new XFillBmpStretchItem,
2385 new XFillBmpPosOffsetXItem,
2386 new XFillBmpPosOffsetYItem,
2387 new XFillBackgroundItem,
2388 new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<sal_uInt16>(eUserMetric))
2391 pPool->SetDefaults(&pDefaults);
2394 pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
2395 pPool->FreezeIdRanges(); // the same
2399 ::std::unique_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
2400 // fill it
2401 if ( _xSection.is() )
2402 pDescriptor->Put(SvxBrushItem(::Color(_xSection->getBackColor()),RPTUI_ID_BRUSH));
2403 else
2405 pDescriptor->Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
2406 pDescriptor->Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
2407 ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
2408 pDescriptor->Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
2409 ,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
2410 pDescriptor->Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric)));
2412 uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition));
2413 if ( xPageStyle.is() )
2415 SvxPageItem aPageItem(RPTUI_ID_PAGE);
2416 aPageItem.SetDescName(xPageStyle->getName());
2417 uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW);
2418 aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT);
2419 aPageItem.SetLandscape(getStyleProperty<bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE));
2420 aPageItem.SetNumType(static_cast<SvxNumType>(getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE)));
2421 pDescriptor->Put(aPageItem);
2422 pDescriptor->Put(SvxBrushItem(::Color(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH));
2426 { // want the dialog to be destroyed before our set
2427 ORptPageDialog aDlg(
2428 getFrameWeld(), pDescriptor.get(),_xSection.is()
2429 ? OUString("BackgroundDialog")
2430 : OUString("PageDialog"));
2431 if (aDlg.run() == RET_OK)
2434 // ItemSet->UNO
2435 // UNO-properties
2436 const SfxItemSet* pSet = aDlg.GetOutputItemSet();
2437 if ( _xSection.is() )
2439 const SfxPoolItem* pItem;
2440 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
2441 _xSection->setBackColor(sal_Int32(static_cast<const SvxBrushItem*>(pItem)->GetColor()));
2443 else
2445 uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW);
2446 const OUString sUndoAction(RptResId(RID_STR_UNDO_CHANGEPAGE));
2447 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2448 const SfxPoolItem* pItem = nullptr;
2449 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_SIZE,true,&pItem))
2451 uno::Any aValue;
2452 static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue);
2453 xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue);
2454 resetZoomType();
2457 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_LRSPACE,true,&pItem))
2459 Any aValue;
2460 static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_L_MARGIN);
2461 xProp->setPropertyValue(PROPERTY_LEFTMARGIN,aValue);
2462 static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_R_MARGIN);
2463 xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,aValue);
2465 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_ULSPACE,true,&pItem))
2467 xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()));
2468 xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower()));
2470 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_PAGE,true,&pItem))
2472 const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem);
2473 xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(pPageItem->IsLandscape()));
2474 xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType())));
2475 uno::Any aValue;
2476 pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT);
2477 xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue);
2478 resetZoomType();
2480 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
2482 ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
2483 xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT));
2484 xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor));
2490 catch(const Exception&)
2492 DBG_UNHANDLED_EXCEPTION("reportdesign");
2494 SfxItemPool::Free(pPool);
2496 for (SfxPoolItem* pDefault : pDefaults)
2497 delete pDefault;
2502 sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel)
2504 ::osl::MutexGuard aGuard( getMutex() );
2506 uno::Reference< report::XReportDefinition > xReportDefinition( xModel, UNO_QUERY );
2507 if ( !xReportDefinition.is() )
2508 return false;
2510 uno::Reference< document::XUndoManagerSupplier > xTestSuppUndo( xModel, UNO_QUERY );
2511 if ( !xTestSuppUndo.is() )
2512 return false;
2514 m_xReportDefinition = xReportDefinition;
2515 return true;
2519 void OReportController::openSortingAndGroupingDialog()
2521 if ( !m_xReportDefinition.is() )
2522 return;
2523 if ( !m_pGroupsFloater )
2525 m_pGroupsFloater = VclPtr<OGroupsSortingDialog>::Create(getView(),!isEditable(),this);
2526 SvtViewOptions aDlgOpt(EViewType::Window, OStringToOUString(m_pGroupsFloater->GetHelpId(), RTL_TEXTENCODING_UTF8));
2527 if ( aDlgOpt.Exists() )
2528 m_pGroupsFloater->SetWindowState(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US));
2529 m_pGroupsFloater->AddEventListener(LINK(this,OReportController,EventLstHdl));
2531 else if ( isUiVisible() )
2532 m_pGroupsFloater->Show(!m_pGroupsFloater->IsVisible());
2535 sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup)
2537 return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups().get(),_xGroup);
2541 IMPL_LINK( OReportController, EventLstHdl, VclWindowEvent&, _rEvent, void )
2543 if ( _rEvent.GetId() == VclEventId::WindowClose )
2545 InvalidateFeature(SID_SORTINGANDGROUPING);
2546 InvalidateFeature(SID_FM_ADD_FIELD);
2547 InvalidateFeature(SID_RPT_SHOWREPORTEXPLORER);
2551 void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint)
2553 const DlgEdHint* pDlgEdHint = dynamic_cast<const DlgEdHint*>(&_rHint);
2554 if (pDlgEdHint && pDlgEdHint->GetKind() == RPTUI_HINT_SELECTIONCHANGED)
2556 const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount();
2557 if ( m_nSelectionCount != nSelectionCount )
2559 m_nSelectionCount = nSelectionCount;
2560 InvalidateAll();
2562 lang::EventObject aEvent(*this);
2563 m_aSelectionListeners.forEach<view::XSelectionChangeListener>(
2564 [&aEvent] (uno::Reference<view::XSelectionChangeListener> const& xListener) {
2565 return xListener->selectionChanged(aEvent);
2571 void OReportController::executeMethodWithUndo(const char* pUndoStrId,const ::std::function<void(ODesignView *)>& _pMemfun)
2573 const OUString sUndoAction = RptResId(pUndoStrId);
2574 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2575 _pMemfun( getDesignView() );
2576 InvalidateFeature( SID_UNDO );
2579 void OReportController::alignControlsWithUndo(const char* pUndoStrId, ControlModification _nControlModification, bool _bAlignAtSection)
2581 const OUString sUndoAction = RptResId(pUndoStrId);
2582 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2583 getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection);
2584 InvalidateFeature( SID_UNDO );
2587 void OReportController::shrinkSectionBottom(const uno::Reference<report::XSection>& _xSection)
2589 const sal_Int32 nElements = _xSection->getCount();
2590 if (nElements == 0)
2592 // there are no elements
2593 return;
2595 const sal_Int32 nSectionHeight = _xSection->getHeight();
2596 sal_Int32 nMaxPositionY = 0;
2597 uno::Reference< report::XReportComponent> xReportComponent;
2599 // for every component get its Y-position and compare it to the current Y-position
2600 for (int i=0;i<nElements;i++)
2602 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2603 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2604 const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2605 const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2606 nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2608 // now we know the minimal Y-Position and maximal Y-Position
2610 if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning
2612 // the lowest position is already 0
2613 return;
2615 _xSection->setHeight(nMaxPositionY);
2618 void OReportController::shrinkSectionTop(const uno::Reference<report::XSection>& _xSection)
2620 const sal_Int32 nElements = _xSection->getCount();
2621 if (nElements == 0)
2623 // there are no elements
2624 return;
2627 const sal_Int32 nSectionHeight = _xSection->getHeight();
2628 sal_Int32 nMinPositionY = nSectionHeight;
2629 uno::Reference< report::XReportComponent> xReportComponent;
2631 // for every component get its Y-position and compare it to the current Y-position
2632 for (int i=0;i<nElements;i++)
2634 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2635 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2636 nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2638 // now we know the minimal Y-Position and maximal Y-Position
2639 if (nMinPositionY == 0)
2641 // the lowest position is already 0
2642 return;
2644 for (int i=0;i<nElements;i++)
2646 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2647 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2648 const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY;
2649 xReportComponent->setPositionY(nNewPositionY);
2651 const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY;
2652 _xSection->setHeight(nNewSectionHeight);
2655 void OReportController::shrinkSection(const char* pUndoStrId, const uno::Reference<report::XSection>& _xSection, sal_Int32 _nSid)
2657 if ( _xSection.is() )
2659 const OUString sUndoAction = RptResId(pUndoStrId);
2660 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2662 if (_nSid == SID_SECTION_SHRINK)
2664 shrinkSectionTop(_xSection);
2665 shrinkSectionBottom(_xSection);
2667 else if (_nSid == SID_SECTION_SHRINK_TOP)
2669 shrinkSectionTop(_xSection);
2671 else if (_nSid == SID_SECTION_SHRINK_BOTTOM)
2673 shrinkSectionBottom(_xSection);
2677 InvalidateFeature( SID_UNDO );
2681 uno::Any SAL_CALL OReportController::getViewData()
2683 ::osl::MutexGuard aGuard( getMutex() );
2685 const sal_Int32 nCommandIDs[] =
2687 SID_GRID_VISIBLE,
2688 SID_GRID_USE,
2689 SID_HELPLINES_MOVE,
2690 SID_RULER,
2691 SID_SHOW_PROPERTYBROWSER,
2692 SID_PROPERTYBROWSER_LAST_PAGE,
2693 SID_SPLIT_POSITION
2696 ::comphelper::NamedValueCollection aCommandProperties;
2697 for (sal_Int32 nCommandID : nCommandIDs)
2699 const FeatureState aFeatureState = GetState( nCommandID );
2701 OUString sCommandURL( getURLForId( nCommandID ).Main );
2702 OSL_ENSURE( sCommandURL.startsWith( ".uno:" ), "OReportController::getViewData: illegal command URL!" );
2703 sCommandURL = sCommandURL.copy( 5 );
2705 Any aCommandState;
2706 if ( !!aFeatureState.bChecked )
2707 aCommandState <<= *aFeatureState.bChecked;
2708 else if ( aFeatureState.aValue.hasValue() )
2709 aCommandState = aFeatureState.aValue;
2711 aCommandProperties.put( sCommandURL, aCommandState );
2714 ::comphelper::NamedValueCollection aViewData;
2715 aViewData.put( "CommandProperties", aCommandProperties.getPropertyValues() );
2717 if ( getDesignView() )
2719 ::std::vector<sal_uInt16> aCollapsedPositions;
2720 getDesignView()->fillCollapsedSections(aCollapsedPositions);
2721 if ( !aCollapsedPositions.empty() )
2723 uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
2724 beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
2725 sal_Int32 i = 1;
2726 for (const auto& rPos : aCollapsedPositions)
2728 pCollapsedIter->Name = PROPERTY_SECTION + OUString::number(i);
2729 pCollapsedIter->Value <<= static_cast<sal_Int32>(rPos);
2730 ++pCollapsedIter;
2731 ++i;
2734 aViewData.put( "CollapsedSections", aCollapsedSections );
2737 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
2738 if ( pSectionWindow )
2740 aViewData.put( "MarkedSection", static_cast<sal_Int32>(pSectionWindow->getReportSection().getPage()->GetPageNum()) );
2744 aViewData.put( "ZoomFactor", m_nZoomValue );
2745 return uno::makeAny( aViewData.getPropertyValues() );
2748 void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data)
2750 ::osl::MutexGuard aGuard( getMutex() );
2754 const ::comphelper::NamedValueCollection aViewData( i_data );
2756 m_aCollapsedSections = aViewData.getOrDefault( "CollapsedSections", m_aCollapsedSections );
2757 m_nPageNum = aViewData.getOrDefault( "MarkedSection", m_nPageNum );
2758 m_nZoomValue = aViewData.getOrDefault( "ZoomFactor", m_nZoomValue );
2759 // TODO: setting those 3 members is not enough - in theory, restoreViewData can be called when the
2760 // view is fully alive, so we need to reflect those 3 values in the view.
2761 // (At the moment, the method is called only during construction phase)
2764 ::comphelper::NamedValueCollection aCommandProperties( aViewData.get( "CommandProperties" ) );
2765 const ::std::vector< OUString > aCommandNames( aCommandProperties.getNames() );
2767 for ( const auto& rCommandName : aCommandNames )
2769 const Any& rCommandValue = aCommandProperties.get( rCommandName );
2770 if ( !rCommandValue.hasValue() )
2771 continue;
2773 if ( getView() )
2775 util::URL aCommand;
2776 aCommand.Complete = ".uno:" + rCommandName;
2778 Sequence< PropertyValue > aCommandArgs(1);
2779 aCommandArgs[0].Name = "Value";
2780 aCommandArgs[0].Value = rCommandValue;
2782 executeUnChecked( aCommand, aCommandArgs );
2784 else
2786 if ( rCommandName == "ShowRuler" )
2787 OSL_VERIFY( rCommandValue >>= m_bShowRuler );
2788 else if ( rCommandName == "HelplinesMove" )
2789 OSL_VERIFY( rCommandValue >>= m_bHelplinesMove );
2790 else if ( rCommandName == "GridVisible" )
2791 OSL_VERIFY( rCommandValue >>= m_bGridVisible );
2792 else if ( rCommandName == "GridUse" )
2793 OSL_VERIFY( rCommandValue >>= m_bGridUse );
2794 else if ( rCommandName == "ControlProperties" )
2795 OSL_VERIFY( rCommandValue >>= m_bShowProperties );
2796 else if ( rCommandName == "LastPropertyBrowserPage" )
2797 OSL_VERIFY( rCommandValue >>= m_sLastActivePage );
2798 else if ( rCommandName == "SplitPosition" )
2799 OSL_VERIFY( rCommandValue >>= m_nSplitPos );
2803 catch(const IllegalArgumentException&)
2805 DBG_UNHANDLED_EXCEPTION("reportdesign");
2809 Reference<XFrame> OReportController::getXFrame()
2811 if ( !m_xFrameLoader.is() )
2813 m_xFrameLoader.set( frame::Desktop::create(m_xContext) );
2815 const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
2816 const OUString sTarget("_blank");
2817 Reference<XFrame> xFrame = m_xFrameLoader->findFrame(sTarget,nFrameSearchFlag);
2818 return xFrame;
2822 uno::Reference<frame::XModel> OReportController::executeReport()
2824 OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?");
2826 uno::Reference<frame::XModel> xModel;
2827 if ( m_xReportDefinition.is() )
2829 const char* pErrorId = RID_ERR_NO_COMMAND;
2830 bool bEnabled = !m_xReportDefinition->getCommand().isEmpty();
2831 if ( bEnabled )
2833 bEnabled = false;
2834 const sal_uInt16 nCount = m_aReportModel->GetPageCount();
2835 sal_uInt16 i = 0;
2836 for (; i < nCount && !bEnabled ; ++i)
2838 const SdrPage* pPage = m_aReportModel->GetPage(i);
2839 bEnabled = pPage->GetObjCount() != 0;
2841 if ( !bEnabled )
2842 pErrorId = RID_ERR_NO_OBJECTS;
2845 dbtools::SQLExceptionInfo aInfo;
2846 if ( !bEnabled )
2848 sdb::SQLContext aFirstMessage;
2849 OUString sInfo = RptResId( pErrorId );
2850 aFirstMessage.Message = sInfo;
2851 aInfo = aFirstMessage;
2852 if ( isEditable() )
2854 sal_uInt16 nCommand = 0;
2855 if (!strcmp(pErrorId, RID_ERR_NO_COMMAND))
2857 if ( !m_bShowProperties )
2858 executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>());
2860 m_sLastActivePage = "Data";
2861 getDesignView()->setCurrentPage(m_sLastActivePage);
2862 nCommand = SID_SELECT_REPORT;
2864 else if ( getDesignView() && !getDesignView()->isAddFieldVisible() )
2866 nCommand = SID_FM_ADD_FIELD;
2868 if ( nCommand )
2870 uno::Sequence< beans::PropertyValue> aArgs;
2871 executeUnChecked(nCommand,aArgs);
2875 else
2877 m_bInGeneratePreview = true;
2880 WaitObject aWait(getView()); // cursor
2881 if ( !m_xReportEngine.is() )
2882 m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
2883 m_xReportEngine->setReportDefinition(m_xReportDefinition);
2884 m_xReportEngine->setActiveConnection(getConnection());
2885 Reference<XFrame> xFrame = getXFrame();
2886 xModel = m_xReportEngine->createDocumentAlive(xFrame);
2888 catch(const sdbc::SQLException&)
2889 { // SQLExceptions and derived exceptions must not be translated
2890 aInfo = ::cppu::getCaughtException();
2892 catch(const uno::Exception& e)
2894 uno::Any aCaughtException( ::cppu::getCaughtException() );
2896 // our first message says: we caught an exception
2897 sdb::SQLContext aFirstMessage;
2898 OUString sInfo(RptResId(RID_STR_CAUGHT_FOREIGN_EXCEPTION));
2899 sInfo = sInfo.replaceAll("$type$", aCaughtException.getValueTypeName());
2900 aFirstMessage.Message = sInfo;
2902 // our second message: the message of the exception we caught
2903 sdbc::SQLException aSecondMessage;
2904 aSecondMessage.Message = e.Message;
2905 aSecondMessage.Context = e.Context;
2907 // maybe our third message: the message which is wrapped in the exception we caught
2908 sdbc::SQLException aThirdMessage;
2909 lang::WrappedTargetException aWrapped;
2910 if ( aCaughtException >>= aWrapped )
2912 aThirdMessage.Message = aWrapped.Message;
2913 aThirdMessage.Context = aWrapped.Context;
2916 if ( !aThirdMessage.Message.isEmpty() )
2917 aSecondMessage.NextException <<= aThirdMessage;
2918 aFirstMessage.NextException <<= aSecondMessage;
2920 aInfo = aFirstMessage;
2922 if (aInfo.isValid())
2924 const OUString suSQLContext = RptResId( RID_STR_COULD_NOT_CREATE_REPORT );
2925 aInfo.prepend(suSQLContext);
2927 m_bInGeneratePreview = false;
2930 if (aInfo.isValid())
2932 showError(aInfo);
2935 return xModel;
2938 uno::Reference< frame::XModel > SAL_CALL OReportController::getModel()
2940 return m_xReportDefinition.get();
2943 uno::Reference< sdbc::XRowSet > const & OReportController::getRowSet()
2945 OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" );
2947 if ( m_xRowSet.is() || !m_xReportDefinition.is() )
2948 return m_xRowSet;
2952 uno::Reference< sdbc::XRowSet > xRowSet(
2953 getORB()->getServiceManager()->createInstanceWithContext("com.sun.star.sdb.RowSet", getORB()),
2954 uno::UNO_QUERY );
2955 uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW );
2957 xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) );
2958 xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( true ) );
2960 std::shared_ptr<AnyConverter> aNoConverter(new AnyConverter);
2961 TPropertyNamePair aPropertyMediation;
2962 aPropertyMediation.emplace( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) );
2963 aPropertyMediation.emplace( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) );
2964 aPropertyMediation.emplace( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) );
2965 aPropertyMediation.emplace( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) );
2967 m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition.get(), xRowSetProp, aPropertyMediation );
2968 m_xRowSet = xRowSet;
2970 catch(const uno::Exception&)
2972 DBG_UNHANDLED_EXCEPTION("reportdesign");
2975 return m_xRowSet;
2978 void OReportController::insertGraphic()
2980 const OUString sTitle(RptResId(RID_STR_IMPORT_GRAPHIC));
2981 // build some arguments for the upcoming dialog
2984 uno::Reference< report::XSection> xSection = getDesignView()->getCurrentSection();
2985 ::sfx2::FileDialogHelper aDialog(ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic, getFrameWeld());
2986 aDialog.SetTitle( sTitle );
2988 uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
2989 xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, css::uno::Any(true));
2990 xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, false/*sal_True*/);
2991 xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, css::uno::Any(true) );
2993 if ( ERRCODE_NONE == aDialog.Execute() )
2995 bool bLink = true;
2996 xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink;
2997 uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
2998 { PROPERTY_IMAGEURL, Any(aDialog.GetPath()) },
2999 { PROPERTY_PRESERVEIRI, Any(bLink) }
3000 }));
3001 createControl(aArgs,xSection,OUString(),OBJ_DLG_IMAGECONTROL);
3004 catch(const Exception&)
3006 DBG_UNHANDLED_EXCEPTION("reportdesign");
3011 sal_Bool SAL_CALL OReportController::select( const Any& aSelection )
3013 ::osl::MutexGuard aGuard( getMutex() );
3014 if ( getDesignView() )
3016 getDesignView()->unmarkAllObjects();
3017 getDesignView()->SetMode(DlgEdMode::Select);
3019 uno::Sequence< uno::Reference<report::XReportComponent> > aElements;
3020 if ( aSelection >>= aElements )
3022 if ( aElements.hasElements() )
3023 getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY));
3024 getDesignView()->setMarked(aElements, true);
3026 else
3028 uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY);
3029 uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY);
3030 if ( xProp.is() )
3032 getDesignView()->showProperties(xObject);
3033 aElements.realloc(1);
3034 aElements[0] = xProp;
3035 getDesignView()->setMarked(aElements, true);
3037 else
3039 uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY);
3040 if ( !xSection.is() && xObject.is() )
3041 getDesignView()->showProperties(xObject);
3042 getDesignView()->setMarked(xSection,xSection.is());
3045 InvalidateAll();
3047 return true;
3050 Any SAL_CALL OReportController::getSelection( )
3052 ::osl::MutexGuard aGuard( getMutex() );
3053 Any aRet;
3054 if ( getDesignView() )
3056 aRet = getDesignView()->getCurrentlyShownProperty();
3057 if ( !aRet.hasValue() )
3058 aRet <<= getDesignView()->getCurrentSection();
3060 return aRet;
3063 void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& Listener )
3065 m_aSelectionListeners.addInterface( Listener );
3068 void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& Listener )
3070 m_aSelectionListeners.removeInterface( Listener );
3073 void OReportController::createNewFunction(const uno::Any& _aValue)
3075 uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW);
3076 const OUString sNewName = RptResId(RID_STR_FUNCTION);
3077 uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext));
3078 xFunction->setName(sNewName);
3079 // the call below will also create an undo action -> listener
3080 xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction));
3083 IMPL_LINK_NOARG( OReportController, OnExecuteReport, void*, void )
3085 executeReport();
3088 void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const OUString& _sFunction,sal_uInt16 _nObjectId)
3090 SequenceAsHashMap aMap(_aArgs);
3091 getDesignView()->setMarked(_xSection, true);
3092 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
3093 if ( !pSectionWindow )
3094 return;
3096 OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the correct one.");
3098 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3099 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3100 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3101 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3102 if ( aPos.X < nLeftMargin )
3103 aPos.X = nLeftMargin;
3105 SdrObject* pNewControl = nullptr;
3106 uno::Reference< report::XReportComponent> xShapeProp;
3107 if ( _nObjectId == OBJ_CUSTOMSHAPE )
3109 pNewControl = SdrObjFactory::MakeNewObject(
3110 *m_aReportModel,
3111 SdrInventor::ReportDesign,
3112 _nObjectId);
3113 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY);
3114 OUString sCustomShapeType = getDesignView()->GetInsertObjString();
3115 if ( sCustomShapeType.isEmpty() )
3116 sCustomShapeType = "diamond";
3117 OReportSection::createDefault(sCustomShapeType,pNewControl);
3118 pNewControl->SetLogicRect(tools::Rectangle(3000,500,6000,3500)); // switch height and width
3120 else if ( _nObjectId == OBJ_OLE2 || OBJ_DLG_SUBREPORT == _nObjectId )
3122 pNewControl = SdrObjFactory::MakeNewObject(
3123 *m_aReportModel,
3124 SdrInventor::ReportDesign,
3125 _nObjectId);
3127 pNewControl->SetLogicRect(tools::Rectangle(3000,500,8000,5500)); // switch height and width
3128 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
3129 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
3130 if ( pObj && !pObj->IsEmpty() )
3132 pObj->initializeChart(getModel());
3135 else
3137 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
3138 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
3140 FmFormView::createControlLabelPair(
3141 getDesignView(),
3142 nLeftMargin,
3144 nullptr,
3145 nullptr,
3146 _nObjectId,
3147 SdrInventor::ReportDesign,
3148 OBJ_DLG_FIXEDTEXT,
3150 // tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
3151 // m_aReportModel seems pretty safe, it's done in other places, initialized
3152 // in impl_initialize and throws a RuntimeException if not existing.
3153 *m_aReportModel,
3155 pLabel,
3156 pControl);
3158 pLabel.reset();
3160 pNewControl = pControl.release();
3161 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pNewControl);
3162 assert(pObj);
3163 if(pObj)
3165 uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
3166 xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
3167 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3168 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3170 const OUString sProps[] = { OUString(PROPERTY_NAME)
3171 ,OUString(PROPERTY_FONTDESCRIPTOR)
3172 ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
3173 ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
3174 ,OUString(PROPERTY_ORIENTATION)
3175 ,OUString(PROPERTY_BORDER)
3176 ,OUString(PROPERTY_FORMATSSUPPLIER)
3177 ,OUString(PROPERTY_BACKGROUNDCOLOR)
3179 for(const auto & sProp : sProps)
3181 if ( xInfo->hasPropertyByName(sProp) && xShapeInfo->hasPropertyByName(sProp) )
3182 xUnoProp->setPropertyValue(sProp,xShapeProp->getPropertyValue(sProp));
3185 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3186 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3189 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && !_sFunction.isEmpty() )
3191 ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
3192 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
3195 sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
3196 if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
3197 xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
3199 OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,OUString());
3200 if ( !sUrl.isEmpty() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
3201 xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
3203 pObj->CreateMediator(true);
3205 if ( _nObjectId == OBJ_DLG_FIXEDTEXT ) // special case for fixed text
3206 xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
3207 else if ( _nObjectId == OBJ_DLG_VFIXEDLINE )
3209 awt::Size aOlSize = xShapeProp->getSize();
3210 xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
3215 const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
3216 if ( nShapeWidth != xShapeProp->getWidth() )
3217 xShapeProp->setWidth( nShapeWidth );
3219 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3220 if ( bChangedPos )
3221 aPos.X = nPaperWidth - nShapeWidth;
3222 xShapeProp->setPosition(aPos);
3224 correctOverlapping(pNewControl,pSectionWindow->getReportSection());
3227 void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
3229 getDesignView()->unmarkAllObjects();
3231 const OUString sUndoAction(RptResId(RID_STR_UNDO_INSERT_CONTROL));
3232 UndoContext aUndoContext( getUndoManager(), sUndoAction );
3234 SequenceAsHashMap aMap(_aArgs);
3235 aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0)));
3237 uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>());
3238 OUString sFunction;
3240 bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE, false);
3241 if ( bDate )
3243 sFunction = "TODAY()";
3244 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3246 bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE, false);
3247 if ( bTime )
3249 sFunction = "TIMEVALUE(NOW())";
3250 aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0));
3251 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3255 void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs)
3257 getDesignView()->unmarkAllObjects();
3259 const OUString sUndoAction(RptResId(RID_STR_UNDO_INSERT_CONTROL));
3260 UndoContext aUndoContext( getUndoManager(), sUndoAction );
3262 if ( !m_xReportDefinition->getPageHeaderOn() )
3264 uno::Sequence< beans::PropertyValue > aArgs;
3265 executeChecked(SID_PAGEHEADERFOOTER,aArgs);
3268 SequenceAsHashMap aMap(_aArgs);
3269 bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE, false);
3271 OUString sFunction( RptResId(STR_RPT_PN_PAGE) );
3272 sFunction = sFunction.replaceFirst("#PAGENUMBER#", "PageNumber()");
3274 if ( bStateOfPage )
3276 sFunction += RptResId(STR_RPT_PN_PAGE_OF);
3277 sFunction = sFunction.replaceFirst("#PAGECOUNT#", "PageCount()");
3280 bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON, true);
3281 createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction);
3285 void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
3287 getDesignView()->unmarkAllObjects();
3289 // the FormatKey determines which field is required
3290 OSectionWindow* pSectionWindow[2];
3291 pSectionWindow[0] = getDesignView()->getMarkedSection();
3293 if ( !pSectionWindow[0] )
3295 select(uno::makeAny(m_xReportDefinition->getDetail()));
3296 pSectionWindow[0] = getDesignView()->getMarkedSection();
3297 if ( !pSectionWindow[0] )
3298 return;
3301 uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection();
3302 UndoContext aUndoContext(getUndoManager(), RptResId(RID_STR_UNDO_INSERT_CONTROL));
3306 bool bHandleOnlyOne = false;
3307 const PropertyValue* pIter = aArgs.getConstArray();
3308 const PropertyValue* pEnd = pIter + aArgs.getLength();
3309 for(;pIter != pEnd && !bHandleOnlyOne;++pIter)
3311 Sequence< PropertyValue > aValue;
3312 if ( !(pIter->Value >>= aValue) )
3313 { // the sequence has only one element which already contains the descriptor
3314 bHandleOnlyOne = true;
3315 aValue = aArgs;
3317 svx::ODataAccessDescriptor aDescriptor(aValue);
3318 SequenceAsHashMap aMap(aValue);
3319 uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault("Section",xCurrentSection);
3320 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
3322 getDesignView()->setMarked(xSection, true);
3323 pSectionWindow[0] = getDesignView()->getMarkedSection();
3325 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3326 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3327 if ( aPos.X < nLeftMargin )
3328 aPos.X = nLeftMargin;
3330 // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down
3331 sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault("DNDAction", sal_Int8(0));
3332 pSectionWindow[1] = pSectionWindow[0];
3333 bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY;
3334 if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK )
3336 // Add the Label one Section up
3337 pSectionWindow[1] = getDesignView()->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST);
3338 if (!pSectionWindow[1])
3340 // maybe out of bounds
3341 pSectionWindow[1] = pSectionWindow[0];
3344 // clear all selections
3345 getDesignView()->unmarkAllObjects();
3347 uno::Reference< beans::XPropertySet > xField( aDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ], uno::UNO_QUERY );
3348 uno::Reference< lang::XComponent > xHoldAlive;
3349 if ( !xField.is() )
3351 OUString sCommand;
3352 OUString sColumnName;
3353 sal_Int32 nCommandType( -1 );
3354 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::Command ] >>= sCommand );
3355 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] >>= sColumnName );
3356 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] >>= nCommandType );
3358 uno::Reference< container::XNameAccess > xColumns;
3359 uno::Reference< sdbc::XConnection > xConnection( getConnection() );
3360 if ( !sCommand.isEmpty() && nCommandType != -1 && !sColumnName.isEmpty() && xConnection.is() )
3362 if ( xReportDefinition->getCommand().isEmpty() )
3364 xReportDefinition->setCommand(sCommand);
3365 xReportDefinition->setCommandType(nCommandType);
3368 xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive);
3369 if ( xColumns.is() && xColumns->hasByName(sColumnName) )
3370 xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY );
3373 if ( !xField.is() )
3375 #if OSL_DEBUG_LEVEL > 0
3378 uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
3379 OUString sRowSetCommand;
3380 sal_Int32 nRowSetCommandType( -1 );
3381 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand );
3382 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType );
3383 OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ),
3384 "OReportController::addPairControls: this only works for a data source which equals our current settings!" );
3385 // if this asserts, then either our row set and our report definition are not in sync, or somebody
3386 // requested the creation of a control/pair for another data source than what our report
3387 // definition is bound to - which is not supported for the parameters case, since we
3388 // can retrieve parameters from the RowSet only.
3390 catch(const Exception&)
3392 DBG_UNHANDLED_EXCEPTION("reportdesign");
3394 #endif
3396 // no column name - perhaps a parameter name?
3397 uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW );
3398 uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_SET_THROW );
3399 sal_Int32 nParamCount( xParams->getCount() );
3400 for ( sal_Int32 i=0; i<nParamCount; ++i)
3402 uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
3403 OUString sParamName;
3404 OSL_VERIFY( xParamCol->getPropertyValue("Name") >>= sParamName );
3405 if ( sParamName == sColumnName )
3407 xField = xParamCol;
3408 break;
3413 if ( !xField.is() )
3414 continue;
3416 sal_uInt16 nOBJID = 0;
3417 sal_Int32 nDataType = sdbc::DataType::BINARY;
3418 xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
3419 switch ( nDataType )
3421 case sdbc::DataType::BINARY:
3422 case sdbc::DataType::VARBINARY:
3423 case sdbc::DataType::LONGVARBINARY:
3424 nOBJID = OBJ_DLG_IMAGECONTROL;
3425 break;
3426 default:
3427 nOBJID = OBJ_DLG_FORMATTEDFIELD;
3428 break;
3431 if ( !nOBJID )
3432 continue;
3434 Reference< util::XNumberFormatsSupplier > xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier();
3435 if ( !xSupplier.is() )
3436 continue;
3438 Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats());
3439 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl[2];
3440 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3441 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3442 OSectionView* pSectionViews[2];
3443 pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView();
3444 pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView();
3446 // find this in svx
3447 FmFormView::createControlLabelPair(
3448 getDesignView(),
3449 nLeftMargin,
3451 xField,
3452 xNumberFormats,
3453 nOBJID,
3454 SdrInventor::ReportDesign,
3455 OBJ_DLG_FIXEDTEXT,
3457 // tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
3458 // m_aReportModel seems pretty safe, it's done in other places, initialized
3459 // in impl_initialize and throws a RuntimeException if not existing.
3460 *m_aReportModel,
3462 pControl[0],
3463 pControl[1]);
3465 if ( pControl[0] && pControl[1] )
3467 SdrPageView* pPgViews[2];
3468 pPgViews[0] = pSectionViews[0]->GetSdrPageView();
3469 pPgViews[1] = pSectionViews[1]->GetSdrPageView();
3470 if ( pPgViews[0] && pPgViews[1] )
3472 OUString sDefaultName;
3473 size_t i = 0;
3474 OUnoObject* pObjs[2];
3475 for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
3477 pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i].get());
3478 assert(pObjs[i]);
3479 uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
3480 uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
3481 xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
3483 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3484 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3485 const OUString sProps[] = { OUString(PROPERTY_FONTDESCRIPTOR)
3486 ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
3487 ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
3488 ,OUString(PROPERTY_BORDER)
3489 ,OUString(PROPERTY_BACKGROUNDCOLOR)
3491 for(const auto & sProp : sProps)
3493 if ( xInfo->hasPropertyByName(sProp) && xShapeInfo->hasPropertyByName(sProp) )
3494 xUnoProp->setPropertyValue(sProp,xShapeProp->getPropertyValue(sProp));
3496 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3498 OUString sName;
3499 xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName;
3500 sDefaultName = sName;
3501 xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName));
3503 ReportFormula aFormula( ReportFormula::Field, sName );
3504 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) );
3507 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3508 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3510 pObjs[i]->CreateMediator(true);
3512 const sal_Int32 nShapeWidth = xShapeProp->getWidth();
3513 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3514 if ( bChangedPos )
3515 aPos.X = nPaperWidth - nShapeWidth;
3516 xShapeProp->setPosition(aPos);
3517 if ( bChangedPos )
3518 aPos.Y += xShapeProp->getHeight();
3519 aPos.X += nShapeWidth;
3521 OUString sLabel;
3522 if ( xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
3523 xField->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
3525 if (pSectionViews[0] != pSectionViews[1] &&
3526 nOBJID == OBJ_DLG_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD
3528 uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3529 uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3530 if ( !sLabel.isEmpty() )
3531 xShapePropTextField->setName(sLabel);
3532 awt::Point aPosLabel = xShapePropLabel->getPosition();
3533 awt::Point aPosTextField = xShapePropTextField->getPosition();
3534 aPosTextField.X = aPosLabel.X;
3535 xShapePropTextField->setPosition(aPosTextField);
3536 if (bLabelAboveTextField)
3538 // move the label down near the splitter
3539 const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection();
3540 aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight();
3542 else
3544 // move the label up to the splitter
3545 aPosLabel.Y = 0;
3547 xShapePropLabel->setPosition(aPosLabel);
3549 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
3550 assert(pObj);
3551 uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
3552 xShapeProp->setName(xShapeProp->getName() + sDefaultName );
3554 for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) // insert controls
3556 correctOverlapping(pControl[i].get(), pSectionWindow[1-i]->getReportSection());
3559 if (!bLabelAboveTextField )
3561 if ( pSectionViews[0] == pSectionViews[1] )
3563 tools::Rectangle aLabel = getRectangleFromControl(pControl[0].get());
3564 tools::Rectangle aTextfield = getRectangleFromControl(pControl[1].get());
3566 // create a Union of the given Label and Textfield
3567 tools::Rectangle aLabelAndTextfield( aLabel );
3568 aLabelAndTextfield.Union(aTextfield);
3570 // check if there exists other fields and if yes, move down
3571 bool bOverlapping = true;
3572 bool bHasToMove = false;
3573 while ( bOverlapping )
3575 const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2);
3576 bOverlapping = pOverlappedObj != nullptr;
3577 if ( bOverlapping )
3579 const tools::Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
3580 aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top());
3581 bHasToMove = true;
3585 if (bHasToMove)
3587 // There was a move down, we need to move the Label and the Textfield down
3588 aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top());
3589 aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
3591 uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3592 xLabel->setPositionY(aLabel.Top());
3594 uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3595 xTextfield->setPositionY(aTextfield.Top());
3600 // not sure where the ownership of these passes too...
3601 pControl[0].release();
3602 pControl[1].release();
3606 catch(const Exception&)
3608 DBG_UNHANDLED_EXCEPTION("reportdesign");
3613 OSectionView* OReportController::getCurrentSectionView() const
3615 OSectionView* pSectionView = nullptr;
3616 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
3617 if ( pSectionWindow )
3618 pSectionView = &pSectionWindow->getReportSection().getSectionView();
3619 return pSectionView;
3622 void OReportController::changeZOrder(sal_Int32 _nId)
3624 OSectionView* pSectionView = getCurrentSectionView();
3625 if ( pSectionView )
3627 switch(_nId)
3629 case SID_FRAME_TO_BOTTOM:
3630 pSectionView->PutMarkedToBtm();
3631 break;
3632 case SID_FRAME_TO_TOP:
3633 pSectionView->PutMarkedToTop();
3634 break;
3635 case SID_FRAME_DOWN:
3636 pSectionView->MovMarkedToBtm();
3637 break;
3638 case SID_FRAME_UP:
3639 pSectionView->MovMarkedToTop();
3640 break;
3642 case SID_OBJECT_HEAVEN:
3643 pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT );
3644 break;
3645 case SID_OBJECT_HELL:
3646 pSectionView->SetMarkedToLayer( RPT_LAYER_BACK );
3647 break;
3652 void OReportController::listen(const bool _bAdd)
3654 const OUString aProps [] = { OUString(PROPERTY_REPORTHEADERON),OUString(PROPERTY_REPORTFOOTERON)
3655 ,OUString(PROPERTY_PAGEHEADERON),OUString(PROPERTY_PAGEFOOTERON)
3656 ,OUString(PROPERTY_COMMAND), OUString(PROPERTY_COMMANDTYPE),OUString(PROPERTY_CAPTION)
3659 void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const OUString&, const uno::Reference< XPropertyChangeListener >& ) =
3660 _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
3662 for (const auto & aProp : aProps)
3663 (m_xReportDefinition.get()->*pPropertyListenerAction)( aProp, static_cast< XPropertyChangeListener* >( this ) );
3665 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3666 uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
3667 uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
3668 const beans::Property* pIter = aSeq.getConstArray();
3669 const beans::Property* pEnd = pIter + aSeq.getLength();
3670 const OUString* pPropsBegin = &aProps[0];
3671 const OUString* pPropsEnd = pPropsBegin + SAL_N_ELEMENTS(aProps) - 3;
3672 for(;pIter != pEnd;++pIter)
3674 if ( ::std::find(pPropsBegin,pPropsEnd,pIter->Name) == pPropsEnd )
3675 (m_xReportDefinition.get()->*pPropertyListenerAction)( pIter->Name, xUndo );
3678 // Add Listeners to UndoEnvironment
3679 void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) =
3680 _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement;
3682 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() );
3683 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() );
3685 // Add Listeners to ReportControllerObserver
3686 OXReportControllerObserver& rObserver = *m_pReportControllerObserver;
3688 if ( m_xReportDefinition->getPageHeaderOn() && _bAdd )
3690 getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER);
3691 rObserver.AddSection(m_xReportDefinition->getPageHeader());
3693 if ( m_xReportDefinition->getReportHeaderOn() && _bAdd )
3695 getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER);
3696 rObserver.AddSection(m_xReportDefinition->getReportHeader());
3699 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3700 const sal_Int32 nCount = xGroups->getCount();
3701 _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv);
3702 _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver);
3704 for (sal_Int32 i=0;i<nCount ; ++i)
3706 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
3707 (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_HEADERON), static_cast< XPropertyChangeListener* >( this ) );
3708 (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_FOOTERON), static_cast< XPropertyChangeListener* >( this ) );
3710 (rUndoEnv.*pElementUndoFunction)( xGroup );
3711 (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() );
3712 if ( xGroup->getHeaderOn() && _bAdd )
3714 getDesignView()->addSection(xGroup->getHeader(),DBGROUPHEADER);
3715 rObserver.AddSection(xGroup->getHeader());
3719 if ( _bAdd )
3721 getDesignView()->addSection(m_xReportDefinition->getDetail(),DBDETAIL);
3722 rObserver.AddSection(m_xReportDefinition->getDetail());
3724 for (sal_Int32 i=nCount;i > 0 ; --i)
3726 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY);
3727 if ( xGroup->getFooterOn() )
3729 getDesignView()->addSection(xGroup->getFooter(),DBGROUPFOOTER);
3730 rObserver.AddSection(xGroup->getFooter());
3733 if ( m_xReportDefinition->getReportFooterOn() )
3735 getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER);
3736 rObserver.AddSection(m_xReportDefinition->getReportFooter());
3738 if ( m_xReportDefinition->getPageFooterOn())
3740 getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
3741 rObserver.AddSection(m_xReportDefinition->getPageFooter());
3744 xGroups->addContainerListener(static_cast<XContainerListener*>(this));
3745 m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this));
3747 else /* ! _bAdd */
3749 rObserver.RemoveSection(m_xReportDefinition->getDetail());
3750 xGroups->removeContainerListener(static_cast<XContainerListener*>(this));
3751 m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this));
3752 m_aReportModel->detachController();
3756 void OReportController::switchReportSection(const sal_Int16 _nId)
3758 OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!");
3760 if ( m_xReportDefinition.is() )
3762 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3763 const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn();
3765 std::unique_ptr< UndoContext > pUndoContext;
3766 if ( SID_REPORTHEADERFOOTER == _nId )
3768 const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3769 pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3771 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel,SID_REPORTHEADER_WITHOUT_UNDO
3772 ,::std::mem_fn(&OReportHelper::getReportHeader)
3773 ,m_xReportDefinition
3774 ,bSwitchOn ? Inserted : Removed
3777 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel,SID_REPORTFOOTER_WITHOUT_UNDO
3778 ,::std::mem_fn(&OReportHelper::getReportFooter)
3779 ,m_xReportDefinition
3780 ,bSwitchOn ? Inserted : Removed
3784 switch( _nId )
3786 case SID_REPORTHEADER_WITHOUT_UNDO:
3787 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3788 break;
3789 case SID_REPORTFOOTER_WITHOUT_UNDO:
3790 m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() );
3791 break;
3792 case SID_REPORTHEADERFOOTER:
3793 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3794 m_xReportDefinition->setReportFooterOn( bSwitchOn );
3795 break;
3798 if ( SID_REPORTHEADERFOOTER == _nId )
3799 pUndoContext.reset();
3800 getView()->Resize();
3804 void OReportController::switchPageSection(const sal_Int16 _nId)
3806 OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!");
3807 if ( m_xReportDefinition.is() )
3809 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3810 const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn();
3812 std::unique_ptr< UndoContext > pUndoContext;
3813 if ( SID_PAGEHEADERFOOTER == _nId )
3815 const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3816 pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3818 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel
3819 ,SID_PAGEHEADER_WITHOUT_UNDO
3820 ,::std::mem_fn(&OReportHelper::getPageHeader)
3821 ,m_xReportDefinition
3822 ,bSwitchOn ? Inserted : Removed
3825 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel
3826 ,SID_PAGEFOOTER_WITHOUT_UNDO
3827 ,::std::mem_fn(&OReportHelper::getPageFooter)
3828 ,m_xReportDefinition
3829 ,bSwitchOn ? Inserted : Removed
3832 switch( _nId )
3834 case SID_PAGEHEADER_WITHOUT_UNDO:
3835 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3836 break;
3837 case SID_PAGEFOOTER_WITHOUT_UNDO:
3838 m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() );
3839 break;
3840 case SID_PAGEHEADERFOOTER:
3841 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3842 m_xReportDefinition->setPageFooterOn( bSwitchOn );
3843 break;
3845 if ( SID_PAGEHEADERFOOTER == _nId )
3846 pUndoContext.reset();
3847 getView()->Resize();
3851 void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs)
3853 if ( !m_xReportDefinition.is() )
3854 return;
3858 const SequenceAsHashMap aMap( _aArgs );
3859 uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() );
3860 if ( !xGroup.is() )
3861 return;
3863 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3864 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3865 if ( _bAppend )
3867 const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() );
3868 xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) );
3869 rUndoEnv.AddElement( xGroup->getFunctions() );
3872 addUndoAction( std::make_unique<OGroupUndo>(
3873 *m_aReportModel,
3874 _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
3875 _bAppend ? Inserted : Removed,
3876 xGroup,
3877 m_xReportDefinition
3878 ) );
3880 if ( !_bAppend )
3882 rUndoEnv.RemoveElement( xGroup->getFunctions() );
3883 const sal_Int32 nPos = getGroupPosition( xGroup );
3884 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3885 xGroups->removeByIndex( nPos );
3888 catch(const Exception&)
3890 DBG_UNHANDLED_EXCEPTION("reportdesign");
3895 void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs)
3897 if ( m_xReportDefinition.is() )
3899 const SequenceAsHashMap aMap(_aArgs);
3900 const bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? OUString(PROPERTY_HEADERON) : OUString(PROPERTY_FOOTERON), false);
3901 uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>());
3902 if ( xGroup.is() )
3904 const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
3905 if ( _bUndo )
3906 addUndoAction(std::make_unique<OGroupSectionUndo>(*m_aReportModel
3907 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
3908 ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter)
3909 ,xGroup
3910 ,bSwitchOn ? Inserted : Removed
3911 , ( _bHeader ?
3912 (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER)
3913 :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER)
3917 if ( _bHeader )
3918 xGroup->setHeaderOn( bSwitchOn );
3919 else
3920 xGroup->setFooterOn( bSwitchOn );
3925 void OReportController::collapseSection(const bool _bCollapse)
3927 OSectionWindow *pSection = getDesignView()->getMarkedSection();
3928 if ( pSection )
3930 pSection->setCollapsed(_bCollapse);
3934 void OReportController::markSection(const bool _bNext)
3936 OSectionWindow *pSection = getDesignView()->getMarkedSection();
3937 if ( pSection )
3939 OSectionWindow *pPrevSection = getDesignView()->getMarkedSection(_bNext ? POST : PREVIOUS);
3940 if ( pPrevSection != pSection && pPrevSection )
3941 select(uno::makeAny(pPrevSection->getReportSection().getSection()));
3942 else
3943 select(uno::makeAny(m_xReportDefinition));
3945 else
3947 getDesignView()->markSection(_bNext ? 0 : getDesignView()->getSectionCount() - 1);
3948 pSection = getDesignView()->getMarkedSection();
3949 if ( pSection )
3950 select(uno::makeAny(pSection->getReportSection().getSection()));
3954 void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs)
3956 uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
3957 if ( !xSection.is() )
3958 xSection = m_xReportDefinition->getDetail();
3960 if ( xSection.is() )
3962 const OUString sKeyModifier("KeyModifier");
3963 const beans::PropertyValue* pIter = _aArgs.getConstArray();
3964 const beans::PropertyValue* pEnd = pIter + _aArgs.getLength();
3965 const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter, pEnd,
3966 [&sKeyModifier] (const beans::PropertyValue& x) -> bool {
3967 return x.Name == sKeyModifier;
3969 sal_Int16 nKeyModifier = 0;
3970 if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) )
3972 Sequence< PropertyValue > aCreateArgs;
3973 getDesignView()->unmarkAllObjects();
3974 createControl(aCreateArgs,xSection,OUString(),getDesignView()->GetInsertObj());
3980 void OReportController::checkChartEnabled()
3982 if ( !m_bChartEnabledAsked )
3984 m_bChartEnabledAsked = true;
3985 const OUString sConfigName( "/org.openoffice.Office.ReportDesign" );
3986 const OUString sPropertyName( "UserData/Chart" );
3990 ::utl::OConfigurationTreeRoot aConfiguration(
3991 ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, sConfigName ) );
3993 bool bChartEnabled = false;
3994 if ( aConfiguration.hasByHierarchicalName(sPropertyName) )
3995 aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled;
3996 m_bChartEnabled = bChartEnabled;
3998 catch(const Exception&)
4005 // css.frame.XTitle
4006 OUString SAL_CALL OReportController::getTitle()
4008 SolarMutexGuard aSolarGuard;
4009 ::osl::MutexGuard aGuard( getMutex() );
4011 uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW);
4013 return xTitle->getTitle ();
4016 void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
4018 _rDefault <<= sal_Int16(100);
4021 // comphelper::OPropertyArrayUsageHelper
4022 ::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const
4024 Sequence< Property > aProps;
4025 describeProperties(aProps);
4026 return new ::cppu::OPropertyArrayHelper(aProps);
4030 // cppu::OPropertySetHelper
4031 ::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper()
4033 return *::comphelper::OPropertyArrayUsageHelper<OReportController_BASE>::getArrayHelper();
4036 void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue)
4038 if ( _nHandle == PROPERTY_ID_ZOOMVALUE )
4040 _aValue >>= m_nZoomValue;
4041 impl_zoom_nothrow();
4044 void SAL_CALL OReportController::setMode( const OUString& aMode )
4046 ::osl::MutexGuard aGuard( getMutex() );
4047 m_sMode = aMode;
4049 OUString SAL_CALL OReportController::getMode( )
4051 ::osl::MutexGuard aGuard( getMutex() );
4052 return m_sMode;
4054 css::uno::Sequence< OUString > SAL_CALL OReportController::getSupportedModes( )
4056 return uno::Sequence< OUString> { OUString("remote"), OUString("normal") };
4058 sal_Bool SAL_CALL OReportController::supportsMode( const OUString& aMode )
4060 uno::Sequence< OUString> aModes = getSupportedModes();
4061 const OUString* pIter = aModes.getConstArray();
4062 const OUString* pEnd = pIter + aModes.getLength();
4063 for(;pIter != pEnd;++pIter)
4065 if ( *pIter == aMode )
4066 break;
4068 return pIter != pEnd;
4071 bool OReportController::isUiVisible() const
4073 return m_sMode != "remote";
4076 void OReportController::impl_fillState_nothrow(const OUString& _sProperty,dbaui::FeatureState& _rState) const
4078 _rState.bEnabled = isEditable();
4079 if ( _rState.bEnabled )
4081 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4082 getDesignView()->fillControlModelSelection(aSelection);
4083 _rState.bEnabled = !aSelection.empty();
4084 if ( _rState.bEnabled )
4086 uno::Any aTemp;
4087 ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin();
4088 for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter)
4090 uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY);
4093 uno::Any aTemp2 = xProp->getPropertyValue(_sProperty);
4094 if ( aIter == aSelection.begin() )
4096 aTemp = aTemp2;
4098 else if ( aTemp != aTemp2 )
4099 break;
4101 catch(const beans::UnknownPropertyException&)
4103 _rState.bEnabled = false;
4106 if ( aIter == aSelection.end() )
4107 _rState.aValue = aTemp;
4112 void OReportController::impl_zoom_nothrow()
4114 Fraction aZoom(m_nZoomValue,100);
4115 setZoomFactor( aZoom,*getDesignView() );
4116 getDesignView()->zoom(aZoom);
4117 InvalidateFeature(SID_ATTR_ZOOM,Reference< XStatusListener >(), true);
4118 InvalidateFeature(SID_ATTR_ZOOMSLIDER,Reference< XStatusListener >(), true);
4121 bool OReportController::isFormatCommandEnabled(sal_uInt16 _nCommand,const uno::Reference< report::XReportControlFormat>& _xReportControlFormat)
4123 bool bRet = false;
4124 if ( _xReportControlFormat.is() && !uno::Reference< report::XFixedLine>(_xReportControlFormat,uno::UNO_QUERY).is() ) // this command is really often called so we need a short cut here
4128 const awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
4130 switch(_nCommand)
4132 case SID_ATTR_CHAR_WEIGHT:
4133 bRet = awt::FontWeight::BOLD == aFontDescriptor.Weight;
4134 break;
4135 case SID_ATTR_CHAR_POSTURE:
4136 bRet = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
4137 break;
4138 case SID_ATTR_CHAR_UNDERLINE:
4139 bRet = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
4140 break;
4141 default:
4145 catch(const uno::Exception&)
4149 return bRet;
4152 bool OReportController::impl_setPropertyAtControls_throw(const char* pUndoResId,const OUString& _sProperty,const uno::Any& _aValue,const Sequence< PropertyValue >& _aArgs)
4154 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4155 uno::Reference< awt::XWindow> xWindow;
4156 lcl_getReportControlFormat( _aArgs, getDesignView(), xWindow, aSelection );
4158 const OUString sUndoAction = RptResId( pUndoResId );
4159 UndoContext aUndoContext( getUndoManager(), sUndoAction );
4161 for (const auto& rxInterface : aSelection)
4163 const uno::Reference< beans::XPropertySet > xControlModel(rxInterface,uno::UNO_QUERY);
4164 if ( xControlModel.is() )
4165 // tdf#117795: some elements may have not some property
4166 // eg class "OFixedLine" doesn't have property "CharFontName"
4167 // so in this case, instead of crashing when selecting all and changing font
4168 // just display a warning
4171 xControlModel->setPropertyValue(_sProperty,_aValue);
4173 catch(const UnknownPropertyException& e)
4175 SAL_WARN("reportdesign", "UnknownPropertyException:" << e);
4179 return !aSelection.empty();
4182 void OReportController::impl_fillCustomShapeState_nothrow(const char* _pCustomShapeType,dbaui::FeatureState& _rState) const
4184 _rState.bEnabled = isEditable();
4185 _rState.bChecked = getDesignView()->GetInsertObj() == OBJ_CUSTOMSHAPE && getDesignView()->GetInsertObjString().equalsAscii(_pCustomShapeType);
4189 OSectionWindow* OReportController::getSectionWindow(const css::uno::Reference< css::report::XSection>& _xSection) const
4191 if ( getDesignView() )
4193 return getDesignView()->getSectionWindow(_xSection);
4196 // throw NullPointerException?
4197 return nullptr;
4201 void OReportController::openZoomDialog()
4203 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
4205 static SfxItemInfo aItemInfos[] =
4207 { SID_ATTR_ZOOM, true }
4209 std::vector<SfxPoolItem*> pDefaults
4211 new SvxZoomItem()
4213 static const sal_uInt16 pRanges[] =
4215 SID_ATTR_ZOOM,SID_ATTR_ZOOM,
4218 SfxItemPool* pPool( new SfxItemPool("ZoomProperties", SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, &pDefaults) );
4219 pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
4220 pPool->FreezeIdRanges(); // the same
4223 ::std::unique_ptr<SfxItemSet> pDescriptor(new SfxItemSet(*pPool, pRanges));
4224 // fill it
4225 SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
4226 aZoomItem.SetValueSet(SvxZoomEnableFlags::N100|SvxZoomEnableFlags::WHOLEPAGE|SvxZoomEnableFlags::PAGEWIDTH);
4227 pDescriptor->Put(aZoomItem);
4229 ScopedVclPtr<AbstractSvxZoomDialog> pDlg(pFact->CreateSvxZoomDialog(nullptr, *pDescriptor));
4230 pDlg->SetLimits( 20, 400 );
4231 bool bCancel = ( RET_CANCEL == pDlg->Execute() );
4233 if ( !bCancel )
4235 const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM );
4236 m_eZoomType = rZoomItem.GetType();
4237 m_nZoomValue = rZoomItem.GetValue();
4238 if ( m_eZoomType != SvxZoomType::PERCENT )
4239 m_nZoomValue = getDesignView()->getZoomFactor( m_eZoomType );
4241 impl_zoom_nothrow();
4244 catch(const uno::Exception&)
4246 DBG_UNHANDLED_EXCEPTION("reportdesign");
4248 SfxItemPool::Free(pPool);
4250 for (SfxPoolItem* pDefault : pDefaults)
4251 delete pDefault;
4255 // XVisualObject
4256 void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize )
4258 ::osl::MutexGuard aGuard( getMutex() );
4259 bool bChanged =
4260 (m_aVisualAreaSize.Width != _aSize.Width ||
4261 m_aVisualAreaSize.Height != _aSize.Height);
4262 m_aVisualAreaSize = _aSize;
4263 if( bChanged )
4264 setModified( true );
4265 m_nAspect = _nAspect;
4268 awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ )
4270 ::osl::MutexGuard aGuard( getMutex() );
4271 return m_aVisualAreaSize;
4274 embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect )
4276 SolarMutexGuard aSolarGuard;
4277 ::osl::MutexGuard aGuard( getMutex() );
4278 embed::VisualRepresentation aResult;
4279 if ( !m_bInGeneratePreview )
4281 m_bInGeneratePreview = true;
4284 if ( !m_xReportEngine.is() )
4285 m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
4286 const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows();
4287 m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW);
4288 m_xReportEngine->setReportDefinition(m_xReportDefinition);
4289 m_xReportEngine->setActiveConnection(getConnection());
4292 Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY);
4293 if ( xTransfer.is() )
4295 xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize);
4296 aResult = xTransfer->getPreferredVisualRepresentation( _nAspect );
4299 catch(const uno::Exception&)
4302 m_xReportEngine->setMaxRows(nOldMaxRows);
4304 catch(const uno::Exception&)
4307 m_bInGeneratePreview = false;
4309 return aResult;
4312 ::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ )
4314 return embed::EmbedMapUnits::ONE_100TH_MM;
4317 uno::Reference< container::XNameAccess > const & OReportController::getColumns() const
4319 if ( !m_xColumns.is() && m_xReportDefinition.is() && !m_xReportDefinition->getCommand().isEmpty() )
4321 m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive);
4323 return m_xColumns;
4326 OUString OReportController::getColumnLabel_throw(const OUString& i_sColumnName) const
4328 OUString sLabel;
4329 uno::Reference< container::XNameAccess > xColumns = getColumns();
4330 if ( xColumns.is() && xColumns->hasByName(i_sColumnName) )
4332 uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW);
4333 if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
4334 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
4336 return sLabel;
4340 SfxUndoManager& OReportController::getUndoManager() const
4342 DBG_TESTSOLARMUTEX();
4343 // this is expected to be called during UI actions, so the SM is assumed to be locked
4345 std::shared_ptr< OReportModel > pReportModel( getSdrModel() );
4346 ENSURE_OR_THROW( !!pReportModel, "no access to our model" );
4348 SfxUndoManager* pUndoManager( pReportModel->GetSdrUndoManager() );
4349 ENSURE_OR_THROW( pUndoManager != nullptr, "no access to our model's UndoManager" );
4351 return *pUndoManager;
4355 void OReportController::clearUndoManager() const
4357 getUndoManager().Clear();
4361 void OReportController::addUndoAction( std::unique_ptr<SfxUndoAction> i_pAction )
4363 getUndoManager().AddUndoAction( std::move(i_pAction) );
4365 InvalidateFeature( SID_UNDO );
4366 InvalidateFeature( SID_REDO );
4368 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */