Use o3tl::convert in Math
[LibreOffice.git] / reportdesign / source / ui / report / ReportController.cxx
blobd765dee2978339791b18edc6025959414c81e25a
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/propertysequence.hxx>
36 #include <comphelper/propertyvalue.hxx>
37 #include <comphelper/sequenceashashmap.hxx>
38 #include <comphelper/types.hxx>
40 #include <connectivity/dbtools.hxx>
41 #include <com/sun/star/style/XStyle.hpp>
42 #include <com/sun/star/style/ParagraphAdjust.hpp>
43 #include <com/sun/star/util/NumberFormatter.hpp>
44 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
45 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
46 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
47 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
48 #include <com/sun/star/frame/FrameSearchFlag.hpp>
49 #include <com/sun/star/container/XChild.hpp>
50 #include <com/sun/star/report/XImageControl.hpp>
51 #include <com/sun/star/report/XFixedLine.hpp>
52 #include <com/sun/star/report/Function.hpp>
53 #include <com/sun/star/awt/FontDescriptor.hpp>
54 #include <com/sun/star/sdb/XParametersSupplier.hpp>
55 #include <com/sun/star/sdb/CommandType.hpp>
56 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
57 #include <com/sun/star/embed/EmbedMapUnits.hpp>
58 #include <com/sun/star/awt/FontWeight.hpp>
59 #include <com/sun/star/awt/FontUnderline.hpp>
60 #include <com/sun/star/awt/FontSlant.hpp>
61 #include <com/sun/star/frame/Desktop.hpp>
62 #include <com/sun/star/frame/status/FontHeight.hpp>
63 #include <com/sun/star/report/ReportEngine.hpp>
64 #include <com/sun/star/report/XFormattedField.hpp>
65 #include <com/sun/star/sdb/SQLContext.hpp>
66 #include <com/sun/star/beans/PropertyAttribute.hpp>
67 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
69 #include <vcl/svapp.hxx>
71 #include <i18nutil/paper.hxx>
72 #include <svx/fmview.hxx>
73 #include <editeng/memberids.h>
74 #include <svx/svxids.hrc>
75 #include <svx/svdobj.hxx>
76 #include <svx/unomid.hxx>
77 #include <svx/dataaccessdescriptor.hxx>
78 #include <svx/xfillit0.hxx>
79 #include <svx/xflclit.hxx>
80 #include <svx/xflgrit.hxx>
81 #include <svx/xflhtit.hxx>
82 #include <svx/xbtmpit.hxx>
83 #include <svx/xflftrit.hxx>
84 #include <svx/xsflclit.hxx>
85 #include <svx/xflbckit.hxx>
86 #include <svx/xflbmpit.hxx>
87 #include <svx/xflbmsli.hxx>
88 #include <svx/xflbmsxy.hxx>
89 #include <svx/xflbmtit.hxx>
90 #include <svx/xflboxy.hxx>
91 #include <svx/xflbstit.hxx>
92 #include <svx/xflbtoxy.hxx>
93 #include <svx/xfltrit.hxx>
94 #include <svx/xgrscit.hxx>
95 #include <editeng/svxenum.hxx>
96 #include <svx/pageitem.hxx>
97 #include <editeng/lrspitem.hxx>
98 #include <editeng/ulspitem.hxx>
99 #include <editeng/sizeitem.hxx>
100 #include <sfx2/zoomitem.hxx>
101 #include <svx/zoomslideritem.hxx>
102 #include <editeng/brushitem.hxx>
103 #include <svx/flagsdef.hxx>
104 #include <svx/svdpagv.hxx>
105 #include <svx/svxdlg.hxx>
107 #include <core_resource.hxx>
108 #include <DesignView.hxx>
109 #include <RptObject.hxx>
110 #include <RptUndo.hxx>
111 #include <strings.hxx>
112 #include <RptDef.hxx>
113 #include <ReportSection.hxx>
114 #include <SectionView.hxx>
115 #include <UndoActions.hxx>
116 #include <dlgpage.hxx>
117 #include <strings.hrc>
119 #include <svl/itempool.hxx>
120 #include <svl/itemset.hxx>
121 #include <svtools/cliplistener.hxx>
122 #include <unotools/syslocale.hxx>
123 #include <unotools/viewoptions.hxx>
124 #include <unotools/localedatawrapper.hxx>
126 #include <osl/mutex.hxx>
127 #include <PropertyForward.hxx>
128 #include <SectionWindow.hxx>
130 #include <toolkit/helper/convert.hxx>
131 #include <GroupsSorting.hxx>
132 #include <PageNumber.hxx>
133 #include <UndoEnv.hxx>
135 #include <memory>
136 #include <string_view>
138 #include <cppuhelper/exc_hlp.hxx>
139 #include <unotools/confignode.hxx>
141 #include <ReportControllerObserver.hxx>
143 #define MAX_ROWS_FOR_PREVIEW 20
145 #define RPTUI_ID_LRSPACE XATTR_FILL_FIRST - 8
146 #define RPTUI_ID_ULSPACE XATTR_FILL_FIRST - 7
147 #define RPTUI_ID_PAGE XATTR_FILL_FIRST - 6
148 #define RPTUI_ID_SIZE XATTR_FILL_FIRST - 5
149 #define RPTUI_ID_PAGE_MODE XATTR_FILL_FIRST - 4
150 #define RPTUI_ID_START XATTR_FILL_FIRST - 3
151 #define RPTUI_ID_END XATTR_FILL_FIRST - 2
152 #define RPTUI_ID_BRUSH XATTR_FILL_FIRST - 1
153 #define RPTUI_ID_METRIC XATTR_FILL_LAST + 1
155 using namespace ::com::sun::star;
156 using namespace uno;
157 using namespace io;
158 using namespace beans;
159 using namespace frame;
160 using namespace util;
161 using namespace lang;
162 using namespace container;
163 using namespace sdbcx;
164 using namespace sdbc;
165 using namespace sdb;
166 using namespace ui;
167 using namespace ui::dialogs;
168 using namespace ::dbtools;
169 using namespace ::rptui;
170 using namespace ::dbaui;
171 using namespace ::comphelper;
172 using namespace ::cppu;
175 namespace
177 void lcl_setFontWPU_nothrow(const uno::Reference< report::XReportControlFormat>& _xReportControlFormat,const sal_Int32 _nId)
179 if ( !_xReportControlFormat.is() )
180 return;
184 awt::FontDescriptor aFontDescriptor = _xReportControlFormat->getFontDescriptor();
185 switch(_nId)
187 case SID_ATTR_CHAR_WEIGHT:
188 aFontDescriptor.Weight = (awt::FontWeight::NORMAL + awt::FontWeight::BOLD) - aFontDescriptor.Weight;
189 break;
190 case SID_ATTR_CHAR_POSTURE:
191 aFontDescriptor.Slant = static_cast<awt::FontSlant>(static_cast<sal_Int16>(awt::FontSlant_ITALIC) - static_cast<sal_Int16>(aFontDescriptor.Slant));
192 break;
193 case SID_ATTR_CHAR_UNDERLINE:
194 aFontDescriptor.Underline = awt::FontUnderline::SINGLE - aFontDescriptor.Underline;
195 break;
196 default:
197 OSL_FAIL("Illegal value in default!");
198 break;
201 _xReportControlFormat->setFontDescriptor(aFontDescriptor);
203 catch(const beans::UnknownPropertyException&)
210 static void lcl_getReportControlFormat(const Sequence< PropertyValue >& aArgs,
211 ODesignView* _pView,
212 uno::Reference< awt::XWindow>& _xWindow,
213 ::std::vector< uno::Reference< uno::XInterface > >& _rControlsFormats)
215 uno::Reference< report::XReportControlFormat> xReportControlFormat;
216 if ( aArgs.hasElements() )
218 SequenceAsHashMap aMap(aArgs);
219 xReportControlFormat = aMap.getUnpackedValueOrDefault(REPORTCONTROLFORMAT,uno::Reference< report::XReportControlFormat>());
220 _xWindow = aMap.getUnpackedValueOrDefault(CURRENT_WINDOW,uno::Reference< awt::XWindow>());
223 if ( !xReportControlFormat.is() )
225 _pView->fillControlModelSelection(_rControlsFormats);
227 else
229 uno::Reference<uno::XInterface> xInterface(xReportControlFormat);
230 _rControlsFormats.push_back(xInterface);
233 if ( !_xWindow.is() )
234 _xWindow = VCLUnoHelper::GetInterface(_pView);
237 OUString SAL_CALL OReportController::getImplementationName()
239 return "com.sun.star.report.comp.ReportDesign";
242 Sequence< OUString> SAL_CALL OReportController::getSupportedServiceNames()
244 return { "com.sun.star.sdb.ReportDesign" };
247 #define PROPERTY_ID_ZOOMVALUE 1
250 OReportController::OReportController(Reference< XComponentContext > const & xContext)
251 :OReportController_BASE(xContext)
252 ,OPropertyStateContainer(OGenericUnoController_Base::rBHelper)
253 ,m_aSelectionListeners( getMutex() )
254 ,m_sMode("normal")
255 ,m_nSplitPos(-1)
256 ,m_nPageNum(-1)
257 ,m_nSelectionCount(0)
258 ,m_nAspect(0)
259 ,m_nZoomValue(100)
260 ,m_eZoomType(SvxZoomType::PERCENT)
261 ,m_bShowRuler(true)
262 ,m_bGridVisible(true)
263 ,m_bGridUse(true)
264 ,m_bShowProperties(true)
265 ,m_bHelplinesMove(true)
266 ,m_bChartEnabled(false)
267 ,m_bChartEnabledAsked(false)
268 ,m_bInGeneratePreview(false)
270 // new Observer
271 m_pReportControllerObserver = new OXReportControllerObserver(*this);
272 registerProperty("ZoomValue", PROPERTY_ID_ZOOMVALUE,
273 beans::PropertyAttribute::BOUND | beans::PropertyAttribute::TRANSIENT,
274 &m_nZoomValue, ::cppu::UnoType<sal_Int16>::get());
278 OReportController::~OReportController()
282 IMPLEMENT_FORWARD_XTYPEPROVIDER2(OReportController,OReportController_BASE,OReportController_Listener)
283 IMPLEMENT_FORWARD_XINTERFACE2(OReportController,OReportController_BASE,OReportController_Listener)
285 void OReportController::disposing()
288 if ( m_pClipboardNotifier.is() )
290 m_pClipboardNotifier->ClearCallbackLink();
291 m_pClipboardNotifier->RemoveListener( getView() );
292 m_pClipboardNotifier.clear();
294 if ( m_xGroupsFloater )
296 SvtViewOptions aDlgOpt(EViewType::Window, OStringToOUString(m_xGroupsFloater->get_help_id(), RTL_TEXTENCODING_UTF8));
297 aDlgOpt.SetWindowState(OStringToOUString(m_xGroupsFloater->getDialog()->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_ASCII_US));
298 if (m_xGroupsFloater->getDialog()->get_visible())
299 m_xGroupsFloater->response(RET_CANCEL);
300 m_xGroupsFloater.reset();
305 m_xHoldAlive.clear();
306 m_xColumns.clear();
307 ::comphelper::disposeComponent( m_xRowSet );
308 ::comphelper::disposeComponent( m_xRowSetMediator );
309 ::comphelper::disposeComponent( m_xFormatter );
311 catch(const uno::Exception&)
313 TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while disposing row sets.");
315 m_xRowSet.clear();
316 m_xRowSetMediator.clear();
318 if ( m_xReportDefinition.is() )
322 OSectionWindow* pSectionWindow = nullptr;
323 if ( getDesignView() )
324 pSectionWindow = getDesignView()->getMarkedSection();
325 if ( pSectionWindow )
326 pSectionWindow->getReportSection().deactivateOle();
327 clearUndoManager();
328 if ( m_aReportModel )
329 listen(false);
330 m_pReportControllerObserver->Clear();
331 m_pReportControllerObserver.clear();
333 catch(const uno::Exception&)
335 DBG_UNHANDLED_EXCEPTION("reportdesign");
340 EventObject aDisposingEvent( *this );
341 m_aSelectionListeners.disposeAndClear( aDisposingEvent );
344 OReportController_BASE::disposing();
349 m_xReportDefinition.clear();
350 m_aReportModel.reset();
351 m_xFrameLoader.clear();
352 m_xReportEngine.clear();
354 catch(const uno::Exception&)
357 if ( getDesignView() )
358 EndListening( *getDesignView() );
359 clearView();
362 FeatureState OReportController::GetState(sal_uInt16 _nId) const
364 FeatureState aReturn;
365 // (disabled automatically)
366 aReturn.bEnabled = false;
367 // check this first
368 if ( !getView() )
369 return aReturn;
371 switch (_nId)
373 case SID_RPT_TEXTDOCUMENT:
374 aReturn.bEnabled = isEditable();
375 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII);
376 break;
377 case SID_RPT_SPREADSHEET:
378 aReturn.bEnabled = isEditable();
379 aReturn.bChecked = (m_xReportDefinition.is() && m_xReportDefinition->getMimeType() == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII);
380 break;
381 case SID_REPORTHEADER_WITHOUT_UNDO:
382 case SID_REPORTFOOTER_WITHOUT_UNDO:
383 case SID_REPORTHEADERFOOTER:
385 aReturn.bEnabled = isEditable();
386 OUString sText = RptResId((m_xReportDefinition.is() && m_xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT);
387 aReturn.sTitle = sText;
389 break;
390 case SID_PAGEHEADER_WITHOUT_UNDO:
391 case SID_PAGEFOOTER_WITHOUT_UNDO:
392 case SID_PAGEHEADERFOOTER:
394 aReturn.bEnabled = isEditable();
395 OUString sText = RptResId((m_xReportDefinition.is() && m_xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT);
396 aReturn.sTitle = sText;
398 break;
399 case SID_GROUP_APPEND:
400 case SID_GROUP_REMOVE:
401 case SID_GROUPHEADER_WITHOUT_UNDO:
402 case SID_GROUPHEADER:
403 case SID_GROUPFOOTER_WITHOUT_UNDO:
404 case SID_GROUPFOOTER:
405 aReturn.bEnabled = isEditable();
406 break;
407 case SID_ADD_CONTROL_PAIR:
408 aReturn.bEnabled = isEditable();
409 break;
410 case SID_REDO:
411 case SID_UNDO:
413 size_t ( SfxUndoManager::*retrieveCount )( bool const ) const =
414 ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount;
416 SfxUndoManager& rUndoManager( getUndoManager() );
417 aReturn.bEnabled = ( rUndoManager.*retrieveCount )( SfxUndoManager::TopLevel ) > 0;
418 if ( aReturn.bEnabled )
420 // TODO: add "Undo/Redo: prefix"
421 OUString ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const =
422 ( _nId == SID_UNDO ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment;
423 aReturn.sTitle = (rUndoManager.*retrieveComment)( 0, SfxUndoManager::TopLevel );
426 break;
427 case SID_GETUNDOSTRINGS:
428 case SID_GETREDOSTRINGS:
430 size_t ( SfxUndoManager::*retrieveCount )( bool const ) const =
431 ( _nId == SID_GETUNDOSTRINGS ) ? &SfxUndoManager::GetUndoActionCount : &SfxUndoManager::GetRedoActionCount;
433 OUString ( SfxUndoManager::*retrieveComment )( size_t, bool const ) const =
434 ( _nId == SID_GETUNDOSTRINGS ) ? &SfxUndoManager::GetUndoActionComment : &SfxUndoManager::GetRedoActionComment;
436 SfxUndoManager& rUndoManager( getUndoManager() );
437 size_t nCount(( rUndoManager.*retrieveCount )( SfxUndoManager::TopLevel ));
438 Sequence<OUString> aSeq(nCount);
439 auto aSeqRange = asNonConstRange(aSeq);
440 for (size_t n = 0; n < nCount; ++n)
441 aSeqRange[n] = (rUndoManager.*retrieveComment)( n, SfxUndoManager::TopLevel );
442 aReturn.aValue <<= aSeq;
443 aReturn.bEnabled = true;
445 break;
446 case SID_OBJECT_RESIZING:
447 case SID_OBJECT_SMALLESTWIDTH:
448 case SID_OBJECT_SMALLESTHEIGHT:
449 case SID_OBJECT_GREATESTWIDTH:
450 case SID_OBJECT_GREATESTHEIGHT:
451 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
452 if ( aReturn.bEnabled )
453 aReturn.bEnabled = m_nSelectionCount > 1;
454 break;
456 case SID_DISTRIBUTE_HLEFT:
457 case SID_DISTRIBUTE_HCENTER:
458 case SID_DISTRIBUTE_HDISTANCE:
459 case SID_DISTRIBUTE_HRIGHT:
460 case SID_DISTRIBUTE_VTOP:
461 case SID_DISTRIBUTE_VCENTER:
462 case SID_DISTRIBUTE_VDISTANCE:
463 case SID_DISTRIBUTE_VBOTTOM:
464 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
465 if ( aReturn.bEnabled )
467 OSectionView* pSectionView = getCurrentSectionView();
468 aReturn.bEnabled = pSectionView && pSectionView->GetMarkedObjectCount() > 2;
470 break;
471 case SID_ARRANGEMENU:
472 case SID_FRAME_DOWN:
473 case SID_FRAME_UP:
474 case SID_FRAME_TO_TOP:
475 case SID_FRAME_TO_BOTTOM:
476 case SID_OBJECT_HEAVEN:
477 case SID_OBJECT_HELL:
478 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
479 if ( aReturn.bEnabled )
481 OSectionView* pSectionView = getCurrentSectionView();
482 aReturn.bEnabled = pSectionView && pSectionView->OnlyShapesMarked();
483 if ( aReturn.bEnabled )
485 if ( SID_OBJECT_HEAVEN == _nId )
486 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_FRONT;
487 else if ( SID_OBJECT_HELL == _nId )
488 aReturn.bEnabled = pSectionView->GetLayerIdOfMarkedObjects() != RPT_LAYER_BACK;
491 break;
493 case SID_SECTION_SHRINK:
494 case SID_SECTION_SHRINK_TOP:
495 case SID_SECTION_SHRINK_BOTTOM:
497 sal_Int32 nCount = 0;
498 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
499 if ( xSection.is() )
501 nCount = xSection->getCount();
503 aReturn.bEnabled = isEditable() && nCount > 0;
505 break;
506 case SID_OBJECT_ALIGN:
507 case SID_OBJECT_ALIGN_LEFT:
508 case SID_OBJECT_ALIGN_CENTER:
509 case SID_OBJECT_ALIGN_RIGHT:
510 case SID_OBJECT_ALIGN_UP:
511 case SID_OBJECT_ALIGN_MIDDLE:
512 case SID_OBJECT_ALIGN_DOWN:
513 case SID_SECTION_ALIGN:
514 case SID_SECTION_ALIGN_LEFT:
515 case SID_SECTION_ALIGN_CENTER:
516 case SID_SECTION_ALIGN_RIGHT:
517 case SID_SECTION_ALIGN_UP:
518 case SID_SECTION_ALIGN_MIDDLE:
519 case SID_SECTION_ALIGN_DOWN:
520 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection();
521 break;
522 case SID_CUT:
523 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
524 break;
525 case SID_COPY:
526 aReturn.bEnabled = getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
527 break;
528 case SID_PASTE:
529 aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent() && getDesignView()->IsPasteAllowed();
530 break;
531 case SID_SELECTALL:
532 aReturn.bEnabled = !getDesignView()->isHandleEvent();
533 break;
534 case SID_SELECTALL_IN_SECTION:
535 aReturn.bEnabled = !getDesignView()->isHandleEvent();
536 if ( aReturn.bEnabled )
537 aReturn.bEnabled = getCurrentSectionView() != nullptr;
538 break;
539 case SID_ESCAPE:
540 aReturn.bEnabled = getDesignView()->GetMode() == DlgEdMode::Insert;
541 break;
542 case SID_TERMINATE_INPLACEACTIVATION:
543 aReturn.bEnabled = true;
544 break;
545 case SID_SELECT_ALL_EDITS:
546 case SID_SELECT_ALL_LABELS:
547 aReturn.bEnabled = true;
548 break;
549 case SID_RPT_NEW_FUNCTION:
550 aReturn.bEnabled = isEditable();
551 break;
552 case SID_COLLAPSE_SECTION:
553 case SID_EXPAND_SECTION:
554 case SID_NEXT_MARK:
555 case SID_PREV_MARK:
556 aReturn.bEnabled = isEditable() && !getDesignView()->isHandleEvent();
557 break;
558 case SID_SELECT:
559 case SID_SELECT_REPORT:
560 aReturn.bEnabled = true;
561 break;
562 case SID_EXECUTE_REPORT:
563 aReturn.bEnabled = isConnected() && m_xReportDefinition.is();
564 break;
565 case SID_DELETE:
566 aReturn.bEnabled = isEditable() && getDesignView()->HasSelection() && !getDesignView()->isHandleEvent();
567 if ( aReturn.bEnabled )
569 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
570 if ( pSectionWindow )
571 aReturn.bEnabled = !pSectionWindow->getReportSection().isUiActive();
574 OUString sText = RptResId(RID_STR_DELETE);
575 aReturn.sTitle = sText;
577 break;
578 case SID_GRID_VISIBLE:
579 aReturn.bEnabled = isEditable();
580 aReturn.bChecked = m_bGridVisible;
581 break;
582 case SID_GRID_USE:
583 aReturn.bEnabled = isEditable();
584 aReturn.bChecked = m_bGridUse;
585 break;
586 case SID_HELPLINES_MOVE:
587 aReturn.bEnabled = isEditable();
588 aReturn.bChecked = m_bHelplinesMove;
589 break;
590 case SID_RULER:
591 aReturn.bEnabled = isEditable();
592 aReturn.bChecked = m_bShowRuler;
593 break;
594 case SID_OBJECT_SELECT:
595 aReturn.bEnabled = true;
596 aReturn.bChecked = getDesignView()->GetMode() == DlgEdMode::Select;
597 break;
598 case SID_INSERT_DIAGRAM:
599 aReturn.bEnabled = isEditable();
600 aReturn.bInvisible = !m_bChartEnabled;
601 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_OLE2;
602 break;
603 case SID_FM_FIXEDTEXT:
604 aReturn.bEnabled = isEditable();
605 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_RD_FIXEDTEXT;
606 break;
607 case SID_INSERT_HFIXEDLINE:
608 aReturn.bEnabled = isEditable();
609 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_RD_HFIXEDLINE;
610 break;
611 case SID_INSERT_VFIXEDLINE:
612 aReturn.bEnabled = isEditable();
613 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_RD_VFIXEDLINE;
614 break;
615 case SID_FM_EDIT:
616 aReturn.bEnabled = isEditable();
617 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_RD_FORMATTEDFIELD;
618 break;
619 case SID_FM_IMAGECONTROL:
620 aReturn.bEnabled = isEditable();
621 aReturn.bChecked = getDesignView()->GetInsertObj() == OBJ_RD_IMAGECONTROL;
622 break;
623 case SID_DRAWTBX_CS_BASIC:
624 case SID_DRAWTBX_CS_BASIC1:
625 case SID_DRAWTBX_CS_BASIC2:
626 case SID_DRAWTBX_CS_BASIC3:
627 case SID_DRAWTBX_CS_BASIC4:
628 case SID_DRAWTBX_CS_BASIC5:
629 case SID_DRAWTBX_CS_BASIC6:
630 case SID_DRAWTBX_CS_BASIC7:
631 case SID_DRAWTBX_CS_BASIC8:
632 case SID_DRAWTBX_CS_BASIC9:
633 case SID_DRAWTBX_CS_BASIC10:
634 case SID_DRAWTBX_CS_BASIC11:
635 case SID_DRAWTBX_CS_BASIC12:
636 case SID_DRAWTBX_CS_BASIC13:
637 case SID_DRAWTBX_CS_BASIC14:
638 case SID_DRAWTBX_CS_BASIC15:
639 case SID_DRAWTBX_CS_BASIC16:
640 case SID_DRAWTBX_CS_BASIC17:
641 case SID_DRAWTBX_CS_BASIC18:
642 case SID_DRAWTBX_CS_BASIC19:
643 case SID_DRAWTBX_CS_BASIC20:
644 case SID_DRAWTBX_CS_BASIC21:
645 case SID_DRAWTBX_CS_BASIC22:
646 impl_fillCustomShapeState_nothrow("diamond",aReturn);
647 break;
648 case SID_DRAWTBX_CS_SYMBOL:
649 case SID_DRAWTBX_CS_SYMBOL1:
650 case SID_DRAWTBX_CS_SYMBOL2:
651 case SID_DRAWTBX_CS_SYMBOL3:
652 case SID_DRAWTBX_CS_SYMBOL4:
653 case SID_DRAWTBX_CS_SYMBOL5:
654 case SID_DRAWTBX_CS_SYMBOL6:
655 case SID_DRAWTBX_CS_SYMBOL7:
656 case SID_DRAWTBX_CS_SYMBOL8:
657 case SID_DRAWTBX_CS_SYMBOL9:
658 case SID_DRAWTBX_CS_SYMBOL10:
659 case SID_DRAWTBX_CS_SYMBOL11:
660 case SID_DRAWTBX_CS_SYMBOL12:
661 case SID_DRAWTBX_CS_SYMBOL13:
662 case SID_DRAWTBX_CS_SYMBOL14:
663 case SID_DRAWTBX_CS_SYMBOL15:
664 case SID_DRAWTBX_CS_SYMBOL16:
665 case SID_DRAWTBX_CS_SYMBOL17:
666 case SID_DRAWTBX_CS_SYMBOL18:
667 impl_fillCustomShapeState_nothrow("smiley",aReturn);
668 break;
669 case SID_DRAWTBX_CS_ARROW:
670 case SID_DRAWTBX_CS_ARROW1:
671 case SID_DRAWTBX_CS_ARROW2:
672 case SID_DRAWTBX_CS_ARROW3:
673 case SID_DRAWTBX_CS_ARROW4:
674 case SID_DRAWTBX_CS_ARROW5:
675 case SID_DRAWTBX_CS_ARROW6:
676 case SID_DRAWTBX_CS_ARROW7:
677 case SID_DRAWTBX_CS_ARROW8:
678 case SID_DRAWTBX_CS_ARROW9:
679 case SID_DRAWTBX_CS_ARROW10:
680 case SID_DRAWTBX_CS_ARROW11:
681 case SID_DRAWTBX_CS_ARROW12:
682 case SID_DRAWTBX_CS_ARROW13:
683 case SID_DRAWTBX_CS_ARROW14:
684 case SID_DRAWTBX_CS_ARROW15:
685 case SID_DRAWTBX_CS_ARROW16:
686 case SID_DRAWTBX_CS_ARROW17:
687 case SID_DRAWTBX_CS_ARROW18:
688 case SID_DRAWTBX_CS_ARROW19:
689 case SID_DRAWTBX_CS_ARROW20:
690 case SID_DRAWTBX_CS_ARROW21:
691 case SID_DRAWTBX_CS_ARROW22:
692 case SID_DRAWTBX_CS_ARROW23:
693 case SID_DRAWTBX_CS_ARROW24:
694 case SID_DRAWTBX_CS_ARROW25:
695 case SID_DRAWTBX_CS_ARROW26:
696 impl_fillCustomShapeState_nothrow("left-right-arrow",aReturn);
697 break;
698 case SID_DRAWTBX_CS_STAR:
699 case SID_DRAWTBX_CS_STAR1:
700 case SID_DRAWTBX_CS_STAR2:
701 case SID_DRAWTBX_CS_STAR3:
702 case SID_DRAWTBX_CS_STAR4:
703 case SID_DRAWTBX_CS_STAR5:
704 case SID_DRAWTBX_CS_STAR6:
705 case SID_DRAWTBX_CS_STAR7:
706 case SID_DRAWTBX_CS_STAR8:
707 case SID_DRAWTBX_CS_STAR9:
708 case SID_DRAWTBX_CS_STAR10:
709 case SID_DRAWTBX_CS_STAR11:
710 case SID_DRAWTBX_CS_STAR12:
711 impl_fillCustomShapeState_nothrow("star5",aReturn);
712 break;
713 case SID_DRAWTBX_CS_FLOWCHART:
714 case SID_DRAWTBX_CS_FLOWCHART1:
715 case SID_DRAWTBX_CS_FLOWCHART2:
716 case SID_DRAWTBX_CS_FLOWCHART3:
717 case SID_DRAWTBX_CS_FLOWCHART4:
718 case SID_DRAWTBX_CS_FLOWCHART5:
719 case SID_DRAWTBX_CS_FLOWCHART6:
720 case SID_DRAWTBX_CS_FLOWCHART7:
721 case SID_DRAWTBX_CS_FLOWCHART8:
722 case SID_DRAWTBX_CS_FLOWCHART9:
723 case SID_DRAWTBX_CS_FLOWCHART10:
724 case SID_DRAWTBX_CS_FLOWCHART11:
725 case SID_DRAWTBX_CS_FLOWCHART12:
726 case SID_DRAWTBX_CS_FLOWCHART13:
727 case SID_DRAWTBX_CS_FLOWCHART14:
728 case SID_DRAWTBX_CS_FLOWCHART15:
729 case SID_DRAWTBX_CS_FLOWCHART16:
730 case SID_DRAWTBX_CS_FLOWCHART17:
731 case SID_DRAWTBX_CS_FLOWCHART18:
732 case SID_DRAWTBX_CS_FLOWCHART19:
733 case SID_DRAWTBX_CS_FLOWCHART20:
734 case SID_DRAWTBX_CS_FLOWCHART21:
735 case SID_DRAWTBX_CS_FLOWCHART22:
736 case SID_DRAWTBX_CS_FLOWCHART23:
737 case SID_DRAWTBX_CS_FLOWCHART24:
738 case SID_DRAWTBX_CS_FLOWCHART25:
739 case SID_DRAWTBX_CS_FLOWCHART26:
740 case SID_DRAWTBX_CS_FLOWCHART27:
741 case SID_DRAWTBX_CS_FLOWCHART28:
742 impl_fillCustomShapeState_nothrow("flowchart-internal-storage",aReturn);
743 break;
744 case SID_DRAWTBX_CS_CALLOUT:
745 case SID_DRAWTBX_CS_CALLOUT1:
746 case SID_DRAWTBX_CS_CALLOUT2:
747 case SID_DRAWTBX_CS_CALLOUT3:
748 case SID_DRAWTBX_CS_CALLOUT4:
749 case SID_DRAWTBX_CS_CALLOUT5:
750 case SID_DRAWTBX_CS_CALLOUT6:
751 case SID_DRAWTBX_CS_CALLOUT7:
752 impl_fillCustomShapeState_nothrow("round-rectangular-callout",aReturn);
753 break;
754 case SID_RPT_SHOWREPORTEXPLORER:
755 aReturn.bEnabled = m_xReportDefinition.is();
756 aReturn.bChecked = getDesignView() && getDesignView()->isReportExplorerVisible();
757 break;
758 case SID_FM_ADD_FIELD:
759 aReturn.bEnabled = isConnected() && isEditable() && m_xReportDefinition.is()
760 && !m_xReportDefinition->getCommand().isEmpty();
761 aReturn.bChecked = getDesignView() && getDesignView()->isAddFieldVisible();
762 break;
763 case SID_SHOW_PROPERTYBROWSER:
764 aReturn.bEnabled = true;
765 aReturn.bChecked = m_bShowProperties;
766 break;
767 case SID_PROPERTYBROWSER_LAST_PAGE:
768 aReturn.bEnabled = true;
769 aReturn.aValue <<= m_sLastActivePage;
770 break;
771 case SID_SPLIT_POSITION:
772 aReturn.bEnabled = true;
773 aReturn.aValue <<= getSplitPos();
774 break;
775 case SID_SAVEDOC:
776 case SID_SAVEASDOC:
777 case SID_SAVEACOPY:
778 aReturn.bEnabled = isConnected() && isEditable();
779 break;
780 case SID_EDITDOC:
781 aReturn.bChecked = isEditable();
782 break;
783 case SID_PAGEDIALOG:
784 aReturn.bEnabled = isEditable();
785 break;
786 case SID_BACKGROUND_COLOR:
787 impl_fillState_nothrow(PROPERTY_CONTROLBACKGROUND,aReturn);
788 break;
789 case SID_ATTR_CHAR_COLOR_BACKGROUND:
790 aReturn.bEnabled = isEditable();
792 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
793 if ( xSection.is() )
796 aReturn.aValue <<= xSection->getBackColor();
797 const uno::Reference< report::XReportControlModel> xControlModel(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
798 aReturn.bEnabled = !xControlModel.is();
800 catch(const beans::UnknownPropertyException&)
803 else
804 aReturn.bEnabled = false;
806 break;
807 case SID_SORTINGANDGROUPING:
808 aReturn.bEnabled = true;
809 aReturn.bChecked = m_xGroupsFloater && m_xGroupsFloater->getDialog()->get_visible();
810 break;
811 case SID_ATTR_CHAR_WEIGHT:
812 case SID_ATTR_CHAR_POSTURE:
813 case SID_ATTR_CHAR_UNDERLINE:
814 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
815 if ( aReturn.bEnabled )
817 awt::FontDescriptor aFontDescriptor;
818 aReturn.aValue >>= aFontDescriptor;
819 aReturn.aValue.clear();
821 switch(_nId)
823 case SID_ATTR_CHAR_WEIGHT:
824 aReturn.bChecked = awt::FontWeight::BOLD == aFontDescriptor.Weight;
825 break;
826 case SID_ATTR_CHAR_POSTURE:
827 aReturn.bChecked = awt::FontSlant_ITALIC == aFontDescriptor.Slant;
828 break;
829 case SID_ATTR_CHAR_UNDERLINE:
830 aReturn.bChecked = awt::FontUnderline::SINGLE == aFontDescriptor.Underline;
831 break;
832 default:
836 break;
837 case SID_ATTR_CHAR_COLOR:
838 case SID_ATTR_CHAR_COLOR2:
839 impl_fillState_nothrow(PROPERTY_CHARCOLOR,aReturn);
840 break;
841 case SID_ATTR_CHAR_FONT:
842 impl_fillState_nothrow(PROPERTY_FONTDESCRIPTOR,aReturn);
843 break;
844 case SID_ATTR_CHAR_FONTHEIGHT:
845 impl_fillState_nothrow(PROPERTY_CHARHEIGHT,aReturn);
846 if ( aReturn.aValue.hasValue() )
848 frame::status::FontHeight aFontHeight;
849 aReturn.aValue >>= aFontHeight.Height;
850 aReturn.aValue <<= aFontHeight; // another type is needed here, so
852 break;
853 case SID_ATTR_PARA_ADJUST_LEFT:
854 case SID_ATTR_PARA_ADJUST_CENTER:
855 case SID_ATTR_PARA_ADJUST_RIGHT:
856 case SID_ATTR_PARA_ADJUST_BLOCK:
857 impl_fillState_nothrow(PROPERTY_PARAADJUST,aReturn);
858 if ( aReturn.bEnabled )
860 ::sal_Int16 nParaAdjust = 0;
861 if ( aReturn.aValue >>= nParaAdjust )
863 switch(static_cast<style::ParagraphAdjust>(nParaAdjust))
865 case style::ParagraphAdjust_LEFT:
866 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_LEFT;
867 break;
868 case style::ParagraphAdjust_RIGHT:
869 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_RIGHT;
870 break;
871 case style::ParagraphAdjust_BLOCK:
872 case style::ParagraphAdjust_STRETCH:
873 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_BLOCK;
874 break;
875 case style::ParagraphAdjust_CENTER:
876 aReturn.bChecked = _nId == SID_ATTR_PARA_ADJUST_CENTER;
877 break;
878 default: break;
881 aReturn.aValue.clear();
883 break;
885 case SID_INSERT_GRAPHIC:
886 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
887 break;
888 case SID_CHAR_DLG:
889 case SID_SETCONTROLDEFAULTS:
890 aReturn.bEnabled = m_xReportDefinition.is() && isEditable();
891 if ( aReturn.bEnabled )
893 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
894 getDesignView()->fillControlModelSelection(aSelection);
895 aReturn.bEnabled = !aSelection.empty()
896 && std::all_of(aSelection.begin(), aSelection.end(), [](const uno::Reference<uno::XInterface>& rxInterface) {
897 return !uno::Reference<report::XFixedLine>(rxInterface, uno::UNO_QUERY).is()
898 && !uno::Reference<report::XImageControl>(rxInterface, uno::UNO_QUERY).is()
899 && uno::Reference<report::XReportControlFormat>(rxInterface, uno::UNO_QUERY).is(); });
901 break;
902 case SID_CONDITIONALFORMATTING:
904 const uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
905 aReturn.bEnabled = xFormattedField.is();
907 break;
908 case SID_INSERT_FLD_PGNUMBER:
909 case SID_DATETIME:
910 aReturn.bEnabled = m_xReportDefinition.is() && isEditable() && getDesignView()->getCurrentSection().is();
911 break;
912 case SID_EXPORTDOC:
913 case SID_EXPORTDOCASPDF:
914 aReturn.bEnabled = m_xReportDefinition.is();
915 break;
916 case SID_PRINTPREVIEW:
917 aReturn.bEnabled = false;
918 break;
919 case SID_ATTR_ZOOM:
920 aReturn.bEnabled = true;
922 SvxZoomItem aZoom(m_eZoomType,m_nZoomValue);
923 aZoom.SetValueSet(SvxZoomEnableFlags::N50|SvxZoomEnableFlags::N75|SvxZoomEnableFlags::N100|SvxZoomEnableFlags::N200);
924 aZoom.QueryValue(aReturn.aValue);
926 break;
927 case SID_ATTR_ZOOMSLIDER:
928 aReturn.bEnabled = true;
930 SvxZoomSliderItem aZoomSlider(m_nZoomValue,20,400);
931 aZoomSlider.AddSnappingPoint(50);
932 aZoomSlider.AddSnappingPoint(75);
933 aZoomSlider.AddSnappingPoint(100);
934 aZoomSlider.AddSnappingPoint(200);
935 aZoomSlider.QueryValue(aReturn.aValue);
937 break;
938 default:
939 aReturn = OReportController_BASE::GetState(_nId);
941 return aReturn;
945 namespace
947 /** extracts a background color from a dispatched SID_BACKGROUND_COLOR call
949 The dispatch might originate from either the toolbar, or the conditional
950 formatting dialog. In both cases, argument formats are different.
952 util::Color lcl_extractBackgroundColor( const Sequence< PropertyValue >& _rDispatchArgs )
954 util::Color aColor( COL_TRANSPARENT );
955 if ( _rDispatchArgs.getLength() == 1 )
957 OSL_VERIFY( _rDispatchArgs[0].Value >>= aColor );
959 else
961 SequenceAsHashMap aMap( _rDispatchArgs );
962 aColor = aMap.getUnpackedValueOrDefault( PROPERTY_FONTCOLOR, aColor );
964 return aColor;
969 void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs)
971 SolarMutexGuard aSolarGuard;
972 ::osl::MutexGuard aGuard( getMutex() );
974 bool bForceBroadcast = false;
975 switch(_nId)
977 case SID_RPT_TEXTDOCUMENT:
978 if ( m_xReportDefinition.is() )
979 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII );
980 break;
981 case SID_RPT_SPREADSHEET:
982 if (m_xReportDefinition.is() )
983 m_xReportDefinition->setMimeType( MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII );
984 break;
985 case SID_REPORTHEADER_WITHOUT_UNDO:
986 case SID_REPORTFOOTER_WITHOUT_UNDO:
987 case SID_REPORTHEADERFOOTER:
988 switchReportSection(_nId);
989 break;
990 case SID_PAGEHEADER_WITHOUT_UNDO:
991 case SID_PAGEFOOTER_WITHOUT_UNDO:
992 case SID_PAGEHEADERFOOTER:
993 switchPageSection(_nId);
994 break;
995 case SID_GROUP_APPEND:
996 case SID_GROUP_REMOVE:
997 modifyGroup(_nId == SID_GROUP_APPEND,aArgs);
998 break;
999 case SID_GROUPHEADER_WITHOUT_UNDO:
1000 case SID_GROUPHEADER:
1001 createGroupSection(SID_GROUPHEADER == _nId,true,aArgs);
1002 break;
1003 case SID_GROUPFOOTER_WITHOUT_UNDO:
1004 case SID_GROUPFOOTER:
1005 createGroupSection(SID_GROUPFOOTER == _nId,false,aArgs);
1006 break;
1007 case SID_ADD_CONTROL_PAIR:
1008 addPairControls(aArgs);
1009 break;
1010 case SID_REDO:
1011 case SID_UNDO:
1013 const OXUndoEnvironment::OUndoMode aLock( m_aReportModel->GetUndoEnv() );
1014 bool ( SfxUndoManager::*doXDo )() =
1015 ( _nId == SID_UNDO ) ? &SfxUndoManager::Undo : &SfxUndoManager::Redo;
1016 SfxUndoManager& rUndoManager( getUndoManager() );
1018 sal_Int16 nCount(1);
1019 if (aArgs.hasElements() && aArgs[0].Name != "KeyModifier")
1020 aArgs[0].Value >>= nCount;
1021 while (nCount--)
1022 (rUndoManager.*doXDo)();
1023 InvalidateAll();
1024 if (m_xGroupsFloater && m_xGroupsFloater->getDialog()->get_visible())
1025 m_xGroupsFloater->UpdateData();
1027 break;
1028 case SID_CUT:
1029 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Cut));
1030 break;
1031 case SID_COPY:
1032 getDesignView()->Copy();
1033 break;
1034 case SID_PASTE:
1035 executeMethodWithUndo(RID_STR_UNDO_PASTE,::std::mem_fn(&ODesignView::Paste));
1036 break;
1038 case SID_FRAME_TO_TOP:
1039 case SID_FRAME_DOWN:
1040 case SID_FRAME_UP:
1041 case SID_FRAME_TO_BOTTOM:
1042 case SID_OBJECT_HEAVEN:
1043 case SID_OBJECT_HELL:
1044 changeZOrder(_nId);
1045 break;
1046 case SID_DISTRIBUTE_HLEFT:
1047 case SID_DISTRIBUTE_HCENTER:
1048 case SID_DISTRIBUTE_HDISTANCE:
1049 case SID_DISTRIBUTE_HRIGHT:
1050 case SID_DISTRIBUTE_VTOP:
1051 case SID_DISTRIBUTE_VCENTER:
1052 case SID_DISTRIBUTE_VDISTANCE:
1053 case SID_DISTRIBUTE_VBOTTOM:
1055 OSectionView* pSectionView = getCurrentSectionView();
1056 if ( pSectionView )
1057 pSectionView->DistributeMarkedObjects(_nId);
1059 break;
1060 case SID_OBJECT_SMALLESTWIDTH:
1061 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_SMALLEST);
1062 break;
1063 case SID_OBJECT_SMALLESTHEIGHT:
1064 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_SMALLEST);
1065 break;
1066 case SID_OBJECT_GREATESTWIDTH:
1067 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::WIDTH_GREATEST);
1068 break;
1069 case SID_OBJECT_GREATESTHEIGHT:
1070 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::HEIGHT_GREATEST);
1071 break;
1072 case SID_SECTION_ALIGN_LEFT:
1073 case SID_OBJECT_ALIGN_LEFT:
1074 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::LEFT,SID_SECTION_ALIGN_LEFT == _nId);
1075 break;
1076 case SID_SECTION_ALIGN_CENTER:
1077 case SID_OBJECT_ALIGN_CENTER:
1078 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_HORIZONTAL,SID_SECTION_ALIGN_CENTER == _nId);
1079 break;
1080 case SID_SECTION_ALIGN_RIGHT:
1081 case SID_OBJECT_ALIGN_RIGHT:
1082 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::RIGHT,SID_SECTION_ALIGN_RIGHT == _nId);
1083 break;
1084 case SID_SECTION_ALIGN_UP:
1085 case SID_OBJECT_ALIGN_UP:
1086 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::TOP,SID_SECTION_ALIGN_UP == _nId);
1087 break;
1088 case SID_SECTION_ALIGN_MIDDLE:
1089 case SID_OBJECT_ALIGN_MIDDLE:
1090 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::CENTER_VERTICAL,SID_SECTION_ALIGN_MIDDLE == _nId);
1091 break;
1092 case SID_SECTION_ALIGN_DOWN:
1093 case SID_OBJECT_ALIGN_DOWN:
1094 alignControlsWithUndo(RID_STR_UNDO_ALIGNMENT,ControlModification::BOTTOM,SID_SECTION_ALIGN_DOWN == _nId);
1095 break;
1097 case SID_SECTION_SHRINK_BOTTOM:
1098 case SID_SECTION_SHRINK_TOP:
1099 case SID_SECTION_SHRINK:
1101 uno::Reference<report::XSection> xSection = getDesignView()->getCurrentSection();
1102 shrinkSection(RID_STR_UNDO_SHRINK, xSection, _nId);
1104 break;
1106 case SID_SELECTALL:
1107 getDesignView()->SelectAll(OBJ_NONE);
1108 break;
1109 case SID_SELECTALL_IN_SECTION:
1111 OSectionView* pSectionView = getCurrentSectionView();
1112 if ( pSectionView )
1113 pSectionView->MarkAll();
1115 break;
1116 case SID_ESCAPE:
1117 getDesignView()->SetMode(DlgEdMode::Select);
1118 InvalidateFeature( SID_OBJECT_SELECT );
1119 break;
1120 case SID_SELECT_ALL_EDITS:
1121 getDesignView()->SelectAll(OBJ_RD_FORMATTEDFIELD);
1122 break;
1123 case SID_SELECT_ALL_LABELS:
1124 getDesignView()->SelectAll(OBJ_RD_FIXEDTEXT);
1125 break;
1126 case SID_TERMINATE_INPLACEACTIVATION:
1128 OSectionWindow* pSection = getDesignView()->getMarkedSection();
1129 if ( pSection )
1130 pSection->getReportSection().deactivateOle();
1132 break;
1133 case SID_SELECT:
1134 if ( aArgs.getLength() == 1 )
1135 select(aArgs[0].Value);
1136 break;
1137 case SID_SELECT_REPORT:
1138 select(uno::makeAny(m_xReportDefinition));
1139 break;
1140 case SID_EXECUTE_REPORT:
1141 getView()->PostUserEvent(LINK(this, OReportController,OnExecuteReport));
1142 break;
1143 case SID_RPT_NEW_FUNCTION:
1144 createNewFunction(aArgs[0].Value);
1145 break;
1146 case SID_COLLAPSE_SECTION:
1147 collapseSection(true);
1148 break;
1149 case SID_EXPAND_SECTION:
1150 collapseSection(false);
1151 break;
1152 case SID_NEXT_MARK:
1153 markSection(true);
1154 break;
1155 case SID_PREV_MARK:
1156 markSection(false);
1157 break;
1158 case SID_DELETE:
1159 if ( aArgs.getLength() == 1 )
1161 uno::Reference< report::XFunction> xFunction;
1162 aArgs[0].Value >>= xFunction;
1163 if ( xFunction.is() )
1165 uno::Reference< report::XFunctions> xFunctions(xFunction->getParent(),uno::UNO_QUERY_THROW);
1166 sal_Int32 nIndex = getPositionInIndexAccess(xFunctions, xFunction);
1167 const OUString sUndoAction = RptResId(RID_STR_UNDO_REMOVE_FUNCTION);
1168 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1169 xFunctions->removeByIndex(nIndex);
1170 select(uno::makeAny(xFunctions->getParent()));
1171 InvalidateFeature( SID_UNDO );
1174 else
1175 executeMethodWithUndo(RID_STR_UNDO_REMOVE_SELECTION,::std::mem_fn(&ODesignView::Delete));
1176 break;
1177 case SID_GRID_USE:
1178 m_bGridUse = !m_bGridUse;
1179 getDesignView()->setGridSnap(m_bGridUse);
1180 break;
1181 case SID_HELPLINES_MOVE:
1182 m_bHelplinesMove = !m_bHelplinesMove;
1183 getDesignView()->setDragStripes(m_bHelplinesMove);
1184 break;
1185 case SID_GRID_VISIBLE:
1186 m_bGridVisible = !m_bGridVisible;
1187 getDesignView()->toggleGrid(m_bGridVisible);
1188 break;
1189 case SID_RULER:
1190 m_bShowRuler = !m_bShowRuler;
1191 getDesignView()->showRuler(m_bShowRuler);
1192 break;
1193 case SID_OBJECT_SELECT:
1194 getDesignView()->SetMode(DlgEdMode::Select);
1195 InvalidateAll();
1196 break;
1197 case SID_INSERT_DIAGRAM:
1198 getDesignView()->SetMode( DlgEdMode::Insert );
1199 getDesignView()->SetInsertObj( OBJ_OLE2);
1200 createDefaultControl(aArgs);
1201 InvalidateAll();
1202 break;
1203 case SID_FM_FIXEDTEXT:
1204 getDesignView()->SetMode( DlgEdMode::Insert );
1205 getDesignView()->SetInsertObj( OBJ_RD_FIXEDTEXT );
1206 createDefaultControl(aArgs);
1207 InvalidateAll();
1208 break;
1209 case SID_INSERT_HFIXEDLINE:
1210 getDesignView()->SetMode( DlgEdMode::Insert );
1211 getDesignView()->SetInsertObj( OBJ_RD_HFIXEDLINE );
1212 createDefaultControl(aArgs);
1213 InvalidateAll();
1214 break;
1215 case SID_INSERT_VFIXEDLINE:
1216 getDesignView()->SetMode( DlgEdMode::Insert );
1217 getDesignView()->SetInsertObj( OBJ_RD_VFIXEDLINE );
1218 createDefaultControl(aArgs);
1219 InvalidateAll();
1220 break;
1221 case SID_FM_EDIT:
1222 getDesignView()->SetMode( DlgEdMode::Insert );
1223 getDesignView()->SetInsertObj( OBJ_RD_FORMATTEDFIELD );
1224 createDefaultControl(aArgs);
1225 InvalidateAll();
1226 break;
1227 case SID_FM_IMAGECONTROL:
1228 getDesignView()->SetMode( DlgEdMode::Insert );
1229 getDesignView()->SetInsertObj( OBJ_RD_IMAGECONTROL );
1230 createDefaultControl(aArgs);
1231 InvalidateAll();
1232 break;
1233 case SID_DRAWTBX_CS_BASIC:
1234 case SID_DRAWTBX_CS_BASIC1:
1235 case SID_DRAWTBX_CS_BASIC2:
1236 case SID_DRAWTBX_CS_BASIC3:
1237 case SID_DRAWTBX_CS_BASIC4:
1238 case SID_DRAWTBX_CS_BASIC5:
1239 case SID_DRAWTBX_CS_BASIC6:
1240 case SID_DRAWTBX_CS_BASIC7:
1241 case SID_DRAWTBX_CS_BASIC8:
1242 case SID_DRAWTBX_CS_BASIC9:
1243 case SID_DRAWTBX_CS_BASIC10:
1244 case SID_DRAWTBX_CS_BASIC11:
1245 case SID_DRAWTBX_CS_BASIC12:
1246 case SID_DRAWTBX_CS_BASIC13:
1247 case SID_DRAWTBX_CS_BASIC14:
1248 case SID_DRAWTBX_CS_BASIC15:
1249 case SID_DRAWTBX_CS_BASIC16:
1250 case SID_DRAWTBX_CS_BASIC17:
1251 case SID_DRAWTBX_CS_BASIC18:
1252 case SID_DRAWTBX_CS_BASIC19:
1253 case SID_DRAWTBX_CS_BASIC20:
1254 case SID_DRAWTBX_CS_BASIC21:
1255 case SID_DRAWTBX_CS_BASIC22:
1256 case SID_DRAWTBX_CS_SYMBOL1:
1257 case SID_DRAWTBX_CS_SYMBOL2:
1258 case SID_DRAWTBX_CS_SYMBOL3:
1259 case SID_DRAWTBX_CS_SYMBOL4:
1260 case SID_DRAWTBX_CS_SYMBOL5:
1261 case SID_DRAWTBX_CS_SYMBOL6:
1262 case SID_DRAWTBX_CS_SYMBOL7:
1263 case SID_DRAWTBX_CS_SYMBOL8:
1264 case SID_DRAWTBX_CS_SYMBOL9:
1265 case SID_DRAWTBX_CS_SYMBOL10:
1266 case SID_DRAWTBX_CS_SYMBOL11:
1267 case SID_DRAWTBX_CS_SYMBOL12:
1268 case SID_DRAWTBX_CS_SYMBOL13:
1269 case SID_DRAWTBX_CS_SYMBOL14:
1270 case SID_DRAWTBX_CS_SYMBOL15:
1271 case SID_DRAWTBX_CS_SYMBOL16:
1272 case SID_DRAWTBX_CS_SYMBOL17:
1273 case SID_DRAWTBX_CS_SYMBOL18:
1274 case SID_DRAWTBX_CS_ARROW1:
1275 case SID_DRAWTBX_CS_ARROW2:
1276 case SID_DRAWTBX_CS_ARROW3:
1277 case SID_DRAWTBX_CS_ARROW4:
1278 case SID_DRAWTBX_CS_ARROW5:
1279 case SID_DRAWTBX_CS_ARROW6:
1280 case SID_DRAWTBX_CS_ARROW7:
1281 case SID_DRAWTBX_CS_ARROW8:
1282 case SID_DRAWTBX_CS_ARROW9:
1283 case SID_DRAWTBX_CS_ARROW10:
1284 case SID_DRAWTBX_CS_ARROW11:
1285 case SID_DRAWTBX_CS_ARROW12:
1286 case SID_DRAWTBX_CS_ARROW13:
1287 case SID_DRAWTBX_CS_ARROW14:
1288 case SID_DRAWTBX_CS_ARROW15:
1289 case SID_DRAWTBX_CS_ARROW16:
1290 case SID_DRAWTBX_CS_ARROW17:
1291 case SID_DRAWTBX_CS_ARROW18:
1292 case SID_DRAWTBX_CS_ARROW19:
1293 case SID_DRAWTBX_CS_ARROW20:
1294 case SID_DRAWTBX_CS_ARROW21:
1295 case SID_DRAWTBX_CS_ARROW22:
1296 case SID_DRAWTBX_CS_ARROW23:
1297 case SID_DRAWTBX_CS_ARROW24:
1298 case SID_DRAWTBX_CS_ARROW25:
1299 case SID_DRAWTBX_CS_ARROW26:
1300 case SID_DRAWTBX_CS_STAR1:
1301 case SID_DRAWTBX_CS_STAR2:
1302 case SID_DRAWTBX_CS_STAR3:
1303 case SID_DRAWTBX_CS_STAR4:
1304 case SID_DRAWTBX_CS_STAR5:
1305 case SID_DRAWTBX_CS_STAR6:
1306 case SID_DRAWTBX_CS_STAR7:
1307 case SID_DRAWTBX_CS_STAR8:
1308 case SID_DRAWTBX_CS_STAR9:
1309 case SID_DRAWTBX_CS_STAR10:
1310 case SID_DRAWTBX_CS_STAR11:
1311 case SID_DRAWTBX_CS_STAR12:
1312 case SID_DRAWTBX_CS_FLOWCHART1:
1313 case SID_DRAWTBX_CS_FLOWCHART2:
1314 case SID_DRAWTBX_CS_FLOWCHART3:
1315 case SID_DRAWTBX_CS_FLOWCHART4:
1316 case SID_DRAWTBX_CS_FLOWCHART5:
1317 case SID_DRAWTBX_CS_FLOWCHART6:
1318 case SID_DRAWTBX_CS_FLOWCHART7:
1319 case SID_DRAWTBX_CS_FLOWCHART8:
1320 case SID_DRAWTBX_CS_FLOWCHART9:
1321 case SID_DRAWTBX_CS_FLOWCHART10:
1322 case SID_DRAWTBX_CS_FLOWCHART11:
1323 case SID_DRAWTBX_CS_FLOWCHART12:
1324 case SID_DRAWTBX_CS_FLOWCHART13:
1325 case SID_DRAWTBX_CS_FLOWCHART14:
1326 case SID_DRAWTBX_CS_FLOWCHART15:
1327 case SID_DRAWTBX_CS_FLOWCHART16:
1328 case SID_DRAWTBX_CS_FLOWCHART17:
1329 case SID_DRAWTBX_CS_FLOWCHART18:
1330 case SID_DRAWTBX_CS_FLOWCHART19:
1331 case SID_DRAWTBX_CS_FLOWCHART20:
1332 case SID_DRAWTBX_CS_FLOWCHART21:
1333 case SID_DRAWTBX_CS_FLOWCHART22:
1334 case SID_DRAWTBX_CS_FLOWCHART23:
1335 case SID_DRAWTBX_CS_FLOWCHART24:
1336 case SID_DRAWTBX_CS_FLOWCHART25:
1337 case SID_DRAWTBX_CS_FLOWCHART26:
1338 case SID_DRAWTBX_CS_FLOWCHART27:
1339 case SID_DRAWTBX_CS_FLOWCHART28:
1340 case SID_DRAWTBX_CS_CALLOUT1:
1341 case SID_DRAWTBX_CS_CALLOUT2:
1342 case SID_DRAWTBX_CS_CALLOUT3:
1343 case SID_DRAWTBX_CS_CALLOUT4:
1344 case SID_DRAWTBX_CS_CALLOUT5:
1345 case SID_DRAWTBX_CS_CALLOUT6:
1346 case SID_DRAWTBX_CS_CALLOUT7:
1347 case SID_DRAWTBX_CS_SYMBOL:
1348 case SID_DRAWTBX_CS_ARROW:
1349 case SID_DRAWTBX_CS_FLOWCHART:
1350 case SID_DRAWTBX_CS_CALLOUT:
1351 case SID_DRAWTBX_CS_STAR:
1352 getDesignView()->SetMode( DlgEdMode::Insert );
1354 URL aUrl = getURLForId(_nId);
1355 sal_Int32 nIndex = 1;
1356 OUString sType = aUrl.Complete.getToken(0,'.',nIndex);
1357 if ( nIndex == -1 || sType.isEmpty() )
1359 switch(_nId)
1361 case SID_DRAWTBX_CS_SYMBOL:
1362 sType = "smiley";
1363 break;
1364 case SID_DRAWTBX_CS_ARROW:
1365 sType = "left-right-arrow";
1366 break;
1367 case SID_DRAWTBX_CS_FLOWCHART:
1368 sType = "flowchart-internal-storage";
1369 break;
1370 case SID_DRAWTBX_CS_CALLOUT:
1371 sType = "round-rectangular-callout";
1372 break;
1373 case SID_DRAWTBX_CS_STAR:
1374 sType = "star5";
1375 break;
1376 default:
1377 sType = "diamond";
1380 else
1381 sType = aUrl.Complete.getToken(0,'.',nIndex);
1383 getDesignView()->SetInsertObj( OBJ_CUSTOMSHAPE ,sType);
1384 createDefaultControl(aArgs);
1386 InvalidateAll();
1387 break;
1388 case SID_RPT_SHOWREPORTEXPLORER:
1389 if ( isUiVisible() )
1390 getDesignView()->toggleReportExplorer();
1391 break;
1392 case SID_FM_ADD_FIELD:
1393 if ( isUiVisible() )
1394 getDesignView()->toggleAddField();
1395 break;
1396 case SID_SHOW_PROPERTYBROWSER:
1397 if ( m_bShowProperties )
1398 m_sLastActivePage = getDesignView()->getCurrentPage();
1399 else
1400 getDesignView()->setCurrentPage(m_sLastActivePage);
1402 if ( isUiVisible() )
1404 m_bShowProperties = !m_bShowProperties;
1405 if ( aArgs.getLength() == 1 )
1406 aArgs[0].Value >>= m_bShowProperties;
1408 getDesignView()->togglePropertyBrowser(m_bShowProperties);
1410 break;
1411 case SID_PROPERTYBROWSER_LAST_PAGE: // nothing to do
1412 m_sLastActivePage = getDesignView()->getCurrentPage();
1413 break;
1414 case SID_SPLIT_POSITION:
1415 getDesignView()->Resize();
1416 break;
1417 case SID_PAGEDIALOG:
1418 case SID_ATTR_CHAR_COLOR_BACKGROUND:
1420 uno::Reference<report::XSection> xSection;
1421 if (aArgs.getLength() == 1 )
1422 aArgs[0].Value >>= xSection;
1423 else if (_nId == SID_ATTR_CHAR_COLOR_BACKGROUND)
1424 xSection.set(getDesignView()->getMarkedSection()->getReportSection().getSection());
1425 openPageDialog(xSection);
1426 bForceBroadcast = true;
1428 break;
1429 case SID_SORTINGANDGROUPING:
1430 openSortingAndGroupingDialog();
1431 break;
1432 case SID_BACKGROUND_COLOR:
1434 const util::Color aColor( lcl_extractBackgroundColor( aArgs ) );
1435 if ( !impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CONTROLBACKGROUND,uno::makeAny(aColor),aArgs) )
1437 uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
1438 if ( xSection.is() )
1440 xSection->setBackColor( aColor );
1443 bForceBroadcast = true;
1445 break;
1446 case SID_ATTR_CHAR_WEIGHT:
1447 case SID_ATTR_CHAR_POSTURE:
1448 case SID_ATTR_CHAR_UNDERLINE:
1450 uno::Reference< awt::XWindow> xWindow;
1451 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1452 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1454 const OUString sUndoAction(RptResId(RID_STR_UNDO_CHANGEFONT));
1455 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1457 for (const auto& rxControlFormat : aControlsFormats)
1459 uno::Reference< report::XReportControlFormat> xReportControlFormat(rxControlFormat,uno::UNO_QUERY);
1460 lcl_setFontWPU_nothrow(xReportControlFormat,_nId);
1463 break;
1464 case SID_ATTR_CHAR_COLOR:
1465 case SID_ATTR_CHAR_COLOR2:
1466 case SID_ATTR_CHAR_COLOR_EXT:
1468 const SequenceAsHashMap aMap(aArgs);
1469 const util::Color aColor = aMap.getUnpackedValueOrDefault(PROPERTY_FONTCOLOR,util::Color());
1470 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARCOLOR,uno::makeAny(aColor),aArgs);
1471 bForceBroadcast = true;
1473 break;
1474 case SID_ATTR_CHAR_FONT:
1475 if ( aArgs.getLength() == 1 )
1477 awt::FontDescriptor aFont;
1478 if ( aArgs[0].Value >>= aFont )
1480 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARFONTNAME,uno::makeAny(aFont.Name),aArgs);
1483 break;
1484 case SID_ATTR_CHAR_FONTHEIGHT:
1485 if ( aArgs.getLength() == 1 )
1487 float fSelVal = 0.0;
1488 if ( aArgs[0].Value >>= fSelVal )
1489 impl_setPropertyAtControls_throw(RID_STR_UNDO_CHANGEFONT,PROPERTY_CHARHEIGHT,aArgs[0].Value,aArgs);
1491 break;
1492 case SID_ATTR_PARA_ADJUST_LEFT:
1493 case SID_ATTR_PARA_ADJUST_CENTER:
1494 case SID_ATTR_PARA_ADJUST_RIGHT:
1495 case SID_ATTR_PARA_ADJUST_BLOCK:
1497 style::ParagraphAdjust eParagraphAdjust = style::ParagraphAdjust_LEFT;
1498 switch(_nId)
1500 case SID_ATTR_PARA_ADJUST_LEFT:
1501 eParagraphAdjust = style::ParagraphAdjust_LEFT;
1502 break;
1503 case SID_ATTR_PARA_ADJUST_CENTER:
1504 eParagraphAdjust = style::ParagraphAdjust_CENTER;
1505 break;
1506 case SID_ATTR_PARA_ADJUST_RIGHT:
1507 eParagraphAdjust = style::ParagraphAdjust_RIGHT;
1508 break;
1509 case SID_ATTR_PARA_ADJUST_BLOCK:
1510 eParagraphAdjust = style::ParagraphAdjust_BLOCK;
1511 break;
1513 impl_setPropertyAtControls_throw(RID_STR_UNDO_ALIGNMENT,PROPERTY_PARAADJUST,uno::makeAny(static_cast<sal_Int16>(eParagraphAdjust)),aArgs);
1515 InvalidateFeature(SID_ATTR_PARA_ADJUST_LEFT);
1516 InvalidateFeature(SID_ATTR_PARA_ADJUST_CENTER);
1517 InvalidateFeature(SID_ATTR_PARA_ADJUST_RIGHT);
1518 InvalidateFeature(SID_ATTR_PARA_ADJUST_BLOCK);
1520 break;
1521 case SID_CHAR_DLG:
1523 uno::Sequence< beans::NamedValue > aSettings;
1524 uno::Reference< awt::XWindow> xWindow;
1525 ::std::vector< uno::Reference< uno::XInterface > > aControlsFormats;
1526 lcl_getReportControlFormat( aArgs, getDesignView(), xWindow, aControlsFormats );
1528 if ( !aControlsFormats.empty() )
1530 const OUString sUndoAction( RptResId( RID_STR_UNDO_CHANGEFONT ) );
1531 UndoContext aUndoContext( getUndoManager(), sUndoAction );
1533 for (const auto& rxControlFormat : aControlsFormats)
1535 uno::Reference< report::XReportControlFormat > xFormat( rxControlFormat, uno::UNO_QUERY );
1536 if ( !xFormat.is() )
1537 continue;
1539 if ( !aSettings.hasElements() )
1541 ::rptui::openCharDialog( xFormat, xWindow, aSettings );
1542 if ( !aSettings.hasElements() )
1543 break;
1546 applyCharacterSettings( xFormat, aSettings );
1549 InvalidateAll();
1552 break;
1553 case SID_INSERT_GRAPHIC:
1554 insertGraphic();
1555 break;
1556 case SID_SETCONTROLDEFAULTS:
1557 break;
1558 case SID_CONDITIONALFORMATTING:
1560 uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY);
1561 if ( xFormattedField.is() )
1563 ConditionalFormattingDialog aDlg(getFrameWeld(), xFormattedField, *this);
1564 aDlg.run();
1567 break;
1568 case SID_DATETIME:
1569 if ( m_xReportDefinition.is() )
1571 if ( !aArgs.hasElements() )
1573 ODateTimeDialog aDlg(getFrameWeld(), getDesignView()->getCurrentSection(), this);
1574 aDlg.run();
1576 else
1577 createDateTime(aArgs);
1579 break;
1580 case SID_INSERT_FLD_PGNUMBER:
1581 if ( m_xReportDefinition.is() )
1583 if ( !aArgs.hasElements() )
1585 OPageNumberDialog aDlg(getFrameWeld(), m_xReportDefinition, this);
1586 aDlg.run();
1588 else
1589 createPageNumber(aArgs);
1591 break;
1592 case SID_EXPORTDOC:
1593 case SID_EXPORTDOCASPDF:
1594 case SID_PRINTPREVIEW:
1595 break;
1596 case SID_EDITDOC:
1597 if(isEditable())
1598 { // the state should be changed to not editable
1599 setModified(false); // and we are not modified yet
1601 setEditable(!isEditable());
1602 InvalidateAll();
1603 return;
1604 case SID_GROUP:
1605 break;
1606 case SID_ATTR_ZOOM:
1607 if ( !aArgs.hasElements() )
1609 openZoomDialog();
1611 else if ( aArgs.getLength() == 1 && aArgs[0].Name == "Zoom" )
1613 SvxZoomItem aZoomItem;
1614 aZoomItem.PutValue(aArgs[0].Value, 0);
1615 m_nZoomValue = aZoomItem.GetValue();
1616 m_eZoomType = aZoomItem.GetType();
1617 impl_zoom_nothrow();
1619 break;
1620 case SID_ATTR_ZOOMSLIDER:
1621 if ( aArgs.getLength() == 1 && aArgs[0].Name == "ZoomSlider" )
1623 SvxZoomSliderItem aZoomSlider;
1624 aZoomSlider.PutValue(aArgs[0].Value, 0);
1625 m_nZoomValue = aZoomSlider.GetValue();
1626 m_eZoomType = SvxZoomType::PERCENT;
1627 impl_zoom_nothrow();
1629 break;
1630 default:
1631 OReportController_BASE::Execute(_nId,aArgs);
1633 InvalidateFeature(_nId,Reference< XStatusListener >(),bForceBroadcast);
1636 void OReportController::impl_initialize( )
1638 OReportController_BASE::impl_initialize();
1640 const ::comphelper::NamedValueCollection& rArguments( getInitParams() );
1642 rArguments.get_ensureType( PROPERTY_REPORTNAME, m_sName );
1643 if ( m_sName.isEmpty() )
1644 rArguments.get_ensureType( "DocumentTitle", m_sName );
1648 if ( m_xReportDefinition.is() )
1650 getView()->initialize(); // show the windows and fill with our information
1652 m_aReportModel = reportdesign::OReportDefinition::getSdrModel(m_xReportDefinition);
1653 if ( !m_aReportModel )
1654 throw RuntimeException();
1655 m_aReportModel->attachController( *this );
1657 clearUndoManager();
1658 UndoSuppressor aSuppressUndo( getUndoManager() );
1660 ::comphelper::NamedValueCollection aArgs(getModel()->getArgs());
1661 setMode(aArgs.getOrDefault("Mode", OUString("normal")));
1663 listen(true);
1664 setEditable( !m_aReportModel->IsReadOnly() );
1665 m_xFormatter.set(util::NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
1666 m_xFormatter->attachNumberFormatsSupplier(Reference< XNumberFormatsSupplier>(m_xReportDefinition,uno::UNO_QUERY));
1668 utl::MediaDescriptor aDescriptor( m_xReportDefinition->getArgs() );
1669 OUString sHierarchicalDocumentName = aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString());
1671 if ( sHierarchicalDocumentName.isEmpty() && getConnection().is() )
1673 uno::Reference<sdbcx::XTablesSupplier> xTablesSup(getConnection(),uno::UNO_QUERY_THROW);
1674 uno::Reference<container::XNameAccess> xTables = xTablesSup->getTables();
1675 const uno::Sequence< OUString > aNames( xTables->getElementNames() );
1677 if ( aNames.hasElements() )
1679 m_xReportDefinition->setCommand(aNames[0]);
1680 m_xReportDefinition->setCommandType(sdb::CommandType::TABLE);
1684 m_aVisualAreaSize = m_xReportDefinition->getVisualAreaSize(0);
1688 // check if chart is supported by the engine
1689 checkChartEnabled();
1690 // restore the view data
1691 getDesignView()->toggleGrid(m_bGridVisible);
1692 getDesignView()->showRuler(m_bShowRuler);
1693 getDesignView()->togglePropertyBrowser(m_bShowProperties);
1694 getDesignView()->setCurrentPage(m_sLastActivePage);
1695 getDesignView()->unmarkAllObjects();
1697 if ( m_nPageNum != -1 )
1699 if ( m_nPageNum < m_aReportModel->GetPageCount() )
1701 const OReportPage* pPage = dynamic_cast<OReportPage*>(m_aReportModel->GetPage(static_cast<sal_uInt16>(m_nPageNum)));
1702 if ( pPage )
1704 uno::Sequence< beans::PropertyValue> aArgs(1);
1705 aArgs.getArray()[0].Value <<= pPage->getSection();
1706 executeUnChecked(SID_SELECT,aArgs);
1709 else
1710 m_nPageNum = -1;
1712 getDesignView()->collapseSections(m_aCollapsedSections);
1713 impl_zoom_nothrow();
1714 getDesignView()->Resize();
1715 getDesignView()->Invalidate();
1716 InvalidateAll();
1718 if ( m_bShowProperties && m_nPageNum == -1 )
1720 m_sLastActivePage = "Data";
1721 getDesignView()->setCurrentPage(m_sLastActivePage);
1722 uno::Sequence< beans::PropertyValue> aArgs;
1723 executeUnChecked(SID_SELECT_REPORT,aArgs);
1726 setModified(false); // and we are not modified yet
1728 catch(const SQLException&)
1730 DBG_UNHANDLED_EXCEPTION("reportdesign");
1734 IMPL_LINK( OReportController, OnCreateHdl, OAddFieldWindow& ,_rAddFieldDlg, void)
1736 weld::WaitObject aObj(getFrameWeld());
1737 uno::Sequence< beans::PropertyValue > aArgs = _rAddFieldDlg.getSelectedFieldDescriptors();
1738 // we use this way to create undo actions
1739 if ( aArgs.hasElements() )
1741 executeChecked(SID_ADD_CONTROL_PAIR,aArgs);
1745 bool OReportController::Construct(vcl::Window* pParent)
1747 VclPtrInstance<ODesignView> pMyOwnView( pParent, m_xContext, *this );
1748 StartListening( *pMyOwnView );
1749 setView( pMyOwnView );
1751 // now that we have a view we can create the clipboard listener
1752 m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( getView() );
1753 m_aSystemClipboard.StartClipboardListening( );
1754 m_pClipboardNotifier = new TransferableClipboardListener( LINK( this, OReportController, OnClipboardChanged ) );
1755 m_pClipboardNotifier->AddListener( getView() );
1757 OReportController_BASE::Construct(pParent);
1758 return true;
1761 sal_Bool SAL_CALL OReportController::suspend(sal_Bool /*_bSuspend*/)
1763 if ( getBroadcastHelper().bInDispose || getBroadcastHelper().bDisposed )
1764 return true;
1766 SolarMutexGuard aSolarGuard;
1767 ::osl::MutexGuard aGuard( getMutex() );
1769 if ( getView() && getView()->IsInModalMode() )
1770 return false;
1772 // this suspend will be handled in the DBAccess interceptor implementation
1773 return true;
1776 void OReportController::describeSupportedFeatures()
1778 DBSubComponentController::describeSupportedFeatures();
1780 implDescribeSupportedFeature( ".uno:TextDocument", SID_RPT_TEXTDOCUMENT, CommandGroup::APPLICATION );
1781 implDescribeSupportedFeature( ".uno:Spreadsheet", SID_RPT_SPREADSHEET, CommandGroup::APPLICATION );
1783 implDescribeSupportedFeature( ".uno:Redo", SID_REDO, CommandGroup::EDIT );
1784 implDescribeSupportedFeature( ".uno:Undo", SID_UNDO, CommandGroup::EDIT );
1785 implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT );
1786 implDescribeSupportedFeature( ".uno:SelectAllInSection", SID_SELECTALL_IN_SECTION, CommandGroup::EDIT );
1787 implDescribeSupportedFeature( ".uno:Delete", SID_DELETE, CommandGroup::EDIT );
1788 implDescribeSupportedFeature( ".uno:SelectReport", SID_SELECT_REPORT, CommandGroup::EDIT );
1789 implDescribeSupportedFeature( ".uno:ExecuteReport", SID_EXECUTE_REPORT, CommandGroup::EDIT );
1791 implDescribeSupportedFeature( ".uno:GridVisible", SID_GRID_VISIBLE, CommandGroup::VIEW );
1792 implDescribeSupportedFeature( ".uno:GridUse", SID_GRID_USE, CommandGroup::VIEW );
1793 implDescribeSupportedFeature( ".uno:HelplinesMove", SID_HELPLINES_MOVE, CommandGroup::VIEW );
1794 implDescribeSupportedFeature( ".uno:ShowRuler", SID_RULER, CommandGroup::VIEW );
1795 implDescribeSupportedFeature( ".uno:AddField", SID_FM_ADD_FIELD, CommandGroup::VIEW );
1796 implDescribeSupportedFeature( ".uno:ReportNavigator", SID_RPT_SHOWREPORTEXPLORER, CommandGroup::VIEW );
1797 implDescribeSupportedFeature( ".uno:ControlProperties", SID_SHOW_PROPERTYBROWSER, CommandGroup::VIEW );
1798 implDescribeSupportedFeature( ".uno:DbSortingAndGrouping", SID_SORTINGANDGROUPING, CommandGroup::VIEW );
1799 implDescribeSupportedFeature( ".uno:PageHeaderFooter", SID_PAGEHEADERFOOTER, CommandGroup::VIEW );
1800 implDescribeSupportedFeature( ".uno:ReportHeaderFooter", SID_REPORTHEADERFOOTER, CommandGroup::VIEW );
1801 implDescribeSupportedFeature( ".uno:ZoomSlider", SID_ATTR_ZOOMSLIDER );
1802 implDescribeSupportedFeature( ".uno:Zoom", SID_ATTR_ZOOM, CommandGroup::VIEW );
1804 implDescribeSupportedFeature( ".uno:ConditionalFormatting", SID_CONDITIONALFORMATTING, CommandGroup::FORMAT );
1805 implDescribeSupportedFeature( ".uno:PageDialog", SID_PAGEDIALOG, CommandGroup::FORMAT );
1806 implDescribeSupportedFeature( ".uno:ResetAttributes", SID_SETCONTROLDEFAULTS, CommandGroup::FORMAT );
1808 implDescribeSupportedFeature( ".uno:Bold", SID_ATTR_CHAR_WEIGHT, CommandGroup::FORMAT );
1809 implDescribeSupportedFeature( ".uno:Italic", SID_ATTR_CHAR_POSTURE, CommandGroup::FORMAT );
1810 implDescribeSupportedFeature( ".uno:Underline", SID_ATTR_CHAR_UNDERLINE, CommandGroup::FORMAT );
1811 implDescribeSupportedFeature( ".uno:DBBackgroundColor", SID_ATTR_CHAR_COLOR_BACKGROUND, CommandGroup::FORMAT );
1812 implDescribeSupportedFeature( ".uno:BackgroundColor", SID_BACKGROUND_COLOR, CommandGroup::FORMAT );
1813 implDescribeSupportedFeature( ".uno:CharColorExt", SID_ATTR_CHAR_COLOR_EXT);
1814 implDescribeSupportedFeature( ".uno:Color", SID_ATTR_CHAR_COLOR);
1815 implDescribeSupportedFeature( ".uno:FontColor", SID_ATTR_CHAR_COLOR2, CommandGroup::FORMAT );
1816 implDescribeSupportedFeature( ".uno:FontDialog", SID_CHAR_DLG, CommandGroup::FORMAT );
1817 implDescribeSupportedFeature( ".uno:LeftPara", SID_ATTR_PARA_ADJUST_LEFT, CommandGroup::FORMAT );
1818 implDescribeSupportedFeature( ".uno:CenterPara", SID_ATTR_PARA_ADJUST_CENTER, CommandGroup::FORMAT );
1819 implDescribeSupportedFeature( ".uno:RightPara", SID_ATTR_PARA_ADJUST_RIGHT, CommandGroup::FORMAT );
1820 implDescribeSupportedFeature( ".uno:JustifyPara", SID_ATTR_PARA_ADJUST_BLOCK, CommandGroup::FORMAT );
1822 implDescribeSupportedFeature( ".uno:FontHeight", SID_ATTR_CHAR_FONTHEIGHT, CommandGroup::FORMAT );
1823 implDescribeSupportedFeature( ".uno:CharFontName", SID_ATTR_CHAR_FONT, CommandGroup::FORMAT );
1825 implDescribeSupportedFeature( ".uno:ArrangeMenu", SID_ARRANGEMENU, CommandGroup::FORMAT );
1826 implDescribeSupportedFeature( ".uno:BringToFront", SID_FRAME_TO_TOP, CommandGroup::FORMAT );
1827 implDescribeSupportedFeature( ".uno:ObjectBackOne", SID_FRAME_DOWN, CommandGroup::FORMAT );
1828 implDescribeSupportedFeature( ".uno:ObjectForwardOne", SID_FRAME_UP, CommandGroup::FORMAT );
1829 implDescribeSupportedFeature( ".uno:SendToBack", SID_FRAME_TO_BOTTOM, CommandGroup::FORMAT );
1830 implDescribeSupportedFeature( ".uno:SetObjectToForeground", SID_OBJECT_HEAVEN, CommandGroup::FORMAT );
1831 implDescribeSupportedFeature( ".uno:SetObjectToBackground", SID_OBJECT_HELL, CommandGroup::FORMAT );
1833 implDescribeSupportedFeature( ".uno:ObjectAlign", SID_OBJECT_ALIGN, CommandGroup::FORMAT );
1834 implDescribeSupportedFeature( ".uno:ObjectAlignLeft", SID_OBJECT_ALIGN_LEFT, CommandGroup::FORMAT );
1835 implDescribeSupportedFeature( ".uno:AlignCenter", SID_OBJECT_ALIGN_CENTER, CommandGroup::FORMAT );
1836 implDescribeSupportedFeature( ".uno:ObjectAlignRight", SID_OBJECT_ALIGN_RIGHT, CommandGroup::FORMAT );
1837 implDescribeSupportedFeature( ".uno:AlignUp", SID_OBJECT_ALIGN_UP, CommandGroup::FORMAT );
1838 implDescribeSupportedFeature( ".uno:AlignMiddle", SID_OBJECT_ALIGN_MIDDLE, CommandGroup::FORMAT );
1839 implDescribeSupportedFeature( ".uno:AlignDown", SID_OBJECT_ALIGN_DOWN, CommandGroup::FORMAT );
1841 implDescribeSupportedFeature( ".uno:SectionAlign", SID_SECTION_ALIGN );
1842 implDescribeSupportedFeature( ".uno:SectionAlignLeft", SID_SECTION_ALIGN_LEFT, CommandGroup::FORMAT );
1843 implDescribeSupportedFeature( ".uno:SectionAlignCenter", SID_SECTION_ALIGN_CENTER, CommandGroup::FORMAT );
1844 implDescribeSupportedFeature( ".uno:SectionAlignRight", SID_SECTION_ALIGN_RIGHT, CommandGroup::FORMAT );
1845 implDescribeSupportedFeature( ".uno:SectionAlignTop", SID_SECTION_ALIGN_UP, CommandGroup::FORMAT );
1846 implDescribeSupportedFeature( ".uno:SectionAlignMiddle", SID_SECTION_ALIGN_MIDDLE, CommandGroup::FORMAT );
1847 implDescribeSupportedFeature( ".uno:SectionAlignBottom", SID_SECTION_ALIGN_DOWN, CommandGroup::FORMAT );
1848 implDescribeSupportedFeature( ".uno:SectionShrink", SID_SECTION_SHRINK, CommandGroup::FORMAT );
1849 implDescribeSupportedFeature( ".uno:SectionShrinkTop", SID_SECTION_SHRINK_TOP, CommandGroup::FORMAT );
1850 implDescribeSupportedFeature( ".uno:SectionShrinkBottom", SID_SECTION_SHRINK_BOTTOM, CommandGroup::FORMAT );
1852 implDescribeSupportedFeature( ".uno:ObjectResize", SID_OBJECT_RESIZING, CommandGroup::FORMAT );
1853 implDescribeSupportedFeature( ".uno:SmallestWidth", SID_OBJECT_SMALLESTWIDTH, CommandGroup::FORMAT );
1854 implDescribeSupportedFeature( ".uno:SmallestHeight", SID_OBJECT_SMALLESTHEIGHT, CommandGroup::FORMAT );
1855 implDescribeSupportedFeature( ".uno:GreatestWidth", SID_OBJECT_GREATESTWIDTH, CommandGroup::FORMAT );
1856 implDescribeSupportedFeature( ".uno:GreatestHeight", SID_OBJECT_GREATESTHEIGHT, CommandGroup::FORMAT );
1858 implDescribeSupportedFeature( ".uno:DistributeSelection", SID_DISTRIBUTE_DLG, CommandGroup::FORMAT );
1859 implDescribeSupportedFeature( ".uno:DistributeHorzLeft", SID_DISTRIBUTE_HLEFT, CommandGroup::FORMAT );
1860 implDescribeSupportedFeature( ".uno:DistributeHorzCenter", SID_DISTRIBUTE_HCENTER, CommandGroup::FORMAT );
1861 implDescribeSupportedFeature( ".uno:DistributeHorzDistance", SID_DISTRIBUTE_HDISTANCE, CommandGroup::FORMAT );
1862 implDescribeSupportedFeature( ".uno:DistributeHorzRight", SID_DISTRIBUTE_HRIGHT, CommandGroup::FORMAT );
1863 implDescribeSupportedFeature( ".uno:DistributeVertTop", SID_DISTRIBUTE_VTOP, CommandGroup::FORMAT );
1864 implDescribeSupportedFeature( ".uno:DistributeVertCenter", SID_DISTRIBUTE_VCENTER, CommandGroup::FORMAT );
1865 implDescribeSupportedFeature( ".uno:DistributeVertDistance", SID_DISTRIBUTE_VDISTANCE, CommandGroup::FORMAT );
1866 implDescribeSupportedFeature( ".uno:DistributeVertBottom", SID_DISTRIBUTE_VBOTTOM, CommandGroup::FORMAT );
1868 implDescribeSupportedFeature( ".uno:ExportTo", SID_EXPORTDOC, CommandGroup::APPLICATION );
1869 implDescribeSupportedFeature( ".uno:ExportToPDF", SID_EXPORTDOCASPDF, CommandGroup::APPLICATION );
1870 implDescribeSupportedFeature( ".uno:PrintPreview", SID_PRINTPREVIEW, CommandGroup::APPLICATION );
1872 implDescribeSupportedFeature( ".uno:NewDoc", SID_NEWDOC, CommandGroup::DOCUMENT );
1873 implDescribeSupportedFeature( ".uno:Save", SID_SAVEDOC, CommandGroup::DOCUMENT );
1874 implDescribeSupportedFeature( ".uno:SaveAs", SID_SAVEASDOC, CommandGroup::DOCUMENT );
1875 implDescribeSupportedFeature( ".uno:SaveACopy", SID_SAVEACOPY, CommandGroup::DOCUMENT );
1877 implDescribeSupportedFeature( ".uno:InsertPageNumberField", SID_INSERT_FLD_PGNUMBER, CommandGroup::INSERT );
1878 implDescribeSupportedFeature( ".uno:InsertDateTimeField", SID_DATETIME, CommandGroup::INSERT );
1879 implDescribeSupportedFeature( ".uno:InsertObjectChart", SID_INSERT_DIAGRAM, CommandGroup::INSERT );
1880 implDescribeSupportedFeature( ".uno:InsertGraphic", SID_INSERT_GRAPHIC, CommandGroup::INSERT );
1881 // controls
1882 implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT );
1883 implDescribeSupportedFeature( ".uno:Label", SID_FM_FIXEDTEXT, CommandGroup::INSERT );
1884 implDescribeSupportedFeature( ".uno:Edit", SID_FM_EDIT, CommandGroup::INSERT );
1885 implDescribeSupportedFeature( ".uno:ImageControl", SID_FM_IMAGECONTROL, CommandGroup::INSERT );
1886 implDescribeSupportedFeature( ".uno:HFixedLine", SID_INSERT_HFIXEDLINE, CommandGroup::INSERT );
1887 implDescribeSupportedFeature( ".uno:VFixedLine", SID_INSERT_VFIXEDLINE, CommandGroup::INSERT );
1889 // shapes
1890 implDescribeSupportedFeature( ".uno:BasicShapes", SID_DRAWTBX_CS_BASIC, CommandGroup::INSERT );
1891 implDescribeSupportedFeature( ".uno:BasicShapes.rectangle", SID_DRAWTBX_CS_BASIC1, CommandGroup::INSERT );
1892 implDescribeSupportedFeature( ".uno:BasicShapes.round-rectangle",SID_DRAWTBX_CS_BASIC2, CommandGroup::INSERT );
1893 implDescribeSupportedFeature( ".uno:BasicShapes.quadrat", SID_DRAWTBX_CS_BASIC3, CommandGroup::INSERT );
1894 implDescribeSupportedFeature( ".uno:BasicShapes.round-quadrat", SID_DRAWTBX_CS_BASIC4, CommandGroup::INSERT );
1895 implDescribeSupportedFeature( ".uno:BasicShapes.circle", SID_DRAWTBX_CS_BASIC5, CommandGroup::INSERT );
1896 implDescribeSupportedFeature( ".uno:BasicShapes.ellipse", SID_DRAWTBX_CS_BASIC6, CommandGroup::INSERT );
1897 implDescribeSupportedFeature( ".uno:BasicShapes.circle-pie", SID_DRAWTBX_CS_BASIC7, CommandGroup::INSERT );
1898 implDescribeSupportedFeature( ".uno:BasicShapes.isosceles-triangle",SID_DRAWTBX_CS_BASIC8, CommandGroup::INSERT );
1899 implDescribeSupportedFeature( ".uno:BasicShapes.right-triangle",SID_DRAWTBX_CS_BASIC9, CommandGroup::INSERT );
1900 implDescribeSupportedFeature( ".uno:BasicShapes.trapezoid", SID_DRAWTBX_CS_BASIC10, CommandGroup::INSERT );
1901 implDescribeSupportedFeature( ".uno:BasicShapes.diamond", SID_DRAWTBX_CS_BASIC11, CommandGroup::INSERT );
1902 implDescribeSupportedFeature( ".uno:BasicShapes.parallelogram", SID_DRAWTBX_CS_BASIC12, CommandGroup::INSERT );
1903 implDescribeSupportedFeature( ".uno:BasicShapes.pentagon", SID_DRAWTBX_CS_BASIC13, CommandGroup::INSERT );
1904 implDescribeSupportedFeature( ".uno:BasicShapes.hexagon", SID_DRAWTBX_CS_BASIC14, CommandGroup::INSERT );
1905 implDescribeSupportedFeature( ".uno:BasicShapes.octagon", SID_DRAWTBX_CS_BASIC15, CommandGroup::INSERT );
1906 implDescribeSupportedFeature( ".uno:BasicShapes.cross", SID_DRAWTBX_CS_BASIC16, CommandGroup::INSERT );
1907 implDescribeSupportedFeature( ".uno:BasicShapes.ring", SID_DRAWTBX_CS_BASIC17, CommandGroup::INSERT );
1908 implDescribeSupportedFeature( ".uno:BasicShapes.block-arc", SID_DRAWTBX_CS_BASIC18, CommandGroup::INSERT );
1909 implDescribeSupportedFeature( ".uno:BasicShapes.can", SID_DRAWTBX_CS_BASIC19, CommandGroup::INSERT );
1910 implDescribeSupportedFeature( ".uno:BasicShapes.cube", SID_DRAWTBX_CS_BASIC20, CommandGroup::INSERT );
1911 implDescribeSupportedFeature( ".uno:BasicShapes.paper", SID_DRAWTBX_CS_BASIC21, CommandGroup::INSERT );
1912 implDescribeSupportedFeature( ".uno:BasicShapes.frame", SID_DRAWTBX_CS_BASIC22, CommandGroup::INSERT );
1914 implDescribeSupportedFeature( ".uno:SymbolShapes", SID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT );
1916 implDescribeSupportedFeature( ".uno:SymbolShapes.smiley" , SID_DRAWTBX_CS_SYMBOL1, CommandGroup::INSERT );
1917 implDescribeSupportedFeature( ".uno:SymbolShapes.sun" , SID_DRAWTBX_CS_SYMBOL2, CommandGroup::INSERT );
1918 implDescribeSupportedFeature( ".uno:SymbolShapes.moon" , SID_DRAWTBX_CS_SYMBOL3, CommandGroup::INSERT );
1919 implDescribeSupportedFeature( ".uno:SymbolShapes.lightning" , SID_DRAWTBX_CS_SYMBOL4, CommandGroup::INSERT );
1920 implDescribeSupportedFeature( ".uno:SymbolShapes.heart" , SID_DRAWTBX_CS_SYMBOL5, CommandGroup::INSERT );
1921 implDescribeSupportedFeature( ".uno:SymbolShapes.flower" , SID_DRAWTBX_CS_SYMBOL6, CommandGroup::INSERT );
1922 implDescribeSupportedFeature( ".uno:SymbolShapes.cloud" , SID_DRAWTBX_CS_SYMBOL7, CommandGroup::INSERT );
1923 implDescribeSupportedFeature( ".uno:SymbolShapes.forbidden" , SID_DRAWTBX_CS_SYMBOL8, CommandGroup::INSERT );
1924 implDescribeSupportedFeature( ".uno:SymbolShapes.puzzle" , SID_DRAWTBX_CS_SYMBOL9, CommandGroup::INSERT );
1925 implDescribeSupportedFeature( ".uno:SymbolShapes.bracket-pair" ,SID_DRAWTBX_CS_SYMBOL10, CommandGroup::INSERT );
1926 implDescribeSupportedFeature( ".uno:SymbolShapes.left-bracket" ,SID_DRAWTBX_CS_SYMBOL11, CommandGroup::INSERT );
1927 implDescribeSupportedFeature( ".uno:SymbolShapes.right-bracket",SID_DRAWTBX_CS_SYMBOL12, CommandGroup::INSERT );
1928 implDescribeSupportedFeature( ".uno:SymbolShapes.brace-pair" , SID_DRAWTBX_CS_SYMBOL13, CommandGroup::INSERT );
1929 implDescribeSupportedFeature( ".uno:SymbolShapes.left-brace" , SID_DRAWTBX_CS_SYMBOL14, CommandGroup::INSERT );
1930 implDescribeSupportedFeature( ".uno:SymbolShapes.right-brace" , SID_DRAWTBX_CS_SYMBOL15, CommandGroup::INSERT );
1931 implDescribeSupportedFeature( ".uno:SymbolShapes.quad-bevel" , SID_DRAWTBX_CS_SYMBOL16, CommandGroup::INSERT );
1932 implDescribeSupportedFeature( ".uno:SymbolShapes.octagon-bevel",SID_DRAWTBX_CS_SYMBOL17, CommandGroup::INSERT );
1933 implDescribeSupportedFeature( ".uno:SymbolShapes.diamond-bevel",SID_DRAWTBX_CS_SYMBOL18, CommandGroup::INSERT );
1935 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow" , SID_DRAWTBX_CS_ARROW1, CommandGroup::INSERT );
1936 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow" , SID_DRAWTBX_CS_ARROW2, CommandGroup::INSERT );
1937 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow" , SID_DRAWTBX_CS_ARROW3, CommandGroup::INSERT );
1938 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow" , SID_DRAWTBX_CS_ARROW4, CommandGroup::INSERT );
1939 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow" , SID_DRAWTBX_CS_ARROW5, CommandGroup::INSERT );
1940 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow" , SID_DRAWTBX_CS_ARROW6, CommandGroup::INSERT );
1941 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow" , SID_DRAWTBX_CS_ARROW7, CommandGroup::INSERT );
1942 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-down-arrow" , SID_DRAWTBX_CS_ARROW8, CommandGroup::INSERT );
1943 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow" , SID_DRAWTBX_CS_ARROW9, CommandGroup::INSERT );
1944 implDescribeSupportedFeature( ".uno:ArrowShapes.corner-right-arrow" , SID_DRAWTBX_CS_ARROW10, CommandGroup::INSERT );
1945 implDescribeSupportedFeature( ".uno:ArrowShapes.split-arrow" , SID_DRAWTBX_CS_ARROW11, CommandGroup::INSERT );
1946 implDescribeSupportedFeature( ".uno:ArrowShapes.striped-right-arrow" , SID_DRAWTBX_CS_ARROW12, CommandGroup::INSERT );
1947 implDescribeSupportedFeature( ".uno:ArrowShapes.notched-right-arrow" , SID_DRAWTBX_CS_ARROW13, CommandGroup::INSERT );
1948 implDescribeSupportedFeature( ".uno:ArrowShapes.pentagon-right" , SID_DRAWTBX_CS_ARROW14, CommandGroup::INSERT );
1949 implDescribeSupportedFeature( ".uno:ArrowShapes.chevron" , SID_DRAWTBX_CS_ARROW15, CommandGroup::INSERT );
1950 implDescribeSupportedFeature( ".uno:ArrowShapes.right-arrow-callout" , SID_DRAWTBX_CS_ARROW16, CommandGroup::INSERT );
1951 implDescribeSupportedFeature( ".uno:ArrowShapes.left-arrow-callout" , SID_DRAWTBX_CS_ARROW17, CommandGroup::INSERT );
1952 implDescribeSupportedFeature( ".uno:ArrowShapes.up-arrow-callout" , SID_DRAWTBX_CS_ARROW18, CommandGroup::INSERT );
1953 implDescribeSupportedFeature( ".uno:ArrowShapes.down-arrow-callout" , SID_DRAWTBX_CS_ARROW19, CommandGroup::INSERT );
1954 implDescribeSupportedFeature( ".uno:ArrowShapes.left-right-arrow-callout",SID_DRAWTBX_CS_ARROW20, CommandGroup::INSERT );
1955 implDescribeSupportedFeature( ".uno:ArrowShapes.up-down-arrow-callout" ,SID_DRAWTBX_CS_ARROW21, CommandGroup::INSERT );
1956 implDescribeSupportedFeature( ".uno:ArrowShapes.up-right-arrow-callout",SID_DRAWTBX_CS_ARROW22, CommandGroup::INSERT );
1957 implDescribeSupportedFeature( ".uno:ArrowShapes.quad-arrow-callout" , SID_DRAWTBX_CS_ARROW23, CommandGroup::INSERT );
1958 implDescribeSupportedFeature( ".uno:ArrowShapes.circular-arrow" , SID_DRAWTBX_CS_ARROW24, CommandGroup::INSERT );
1959 implDescribeSupportedFeature( ".uno:ArrowShapes.split-round-arrow" , SID_DRAWTBX_CS_ARROW25, CommandGroup::INSERT );
1960 implDescribeSupportedFeature( ".uno:ArrowShapes.s-sharped-arrow" , SID_DRAWTBX_CS_ARROW26, CommandGroup::INSERT );
1962 implDescribeSupportedFeature( ".uno:StarShapes.bang" , SID_DRAWTBX_CS_STAR1, CommandGroup::INSERT );
1963 implDescribeSupportedFeature( ".uno:StarShapes.star4" , SID_DRAWTBX_CS_STAR2, CommandGroup::INSERT );
1964 implDescribeSupportedFeature( ".uno:StarShapes.star5" , SID_DRAWTBX_CS_STAR3, CommandGroup::INSERT );
1965 implDescribeSupportedFeature( ".uno:StarShapes.star6" , SID_DRAWTBX_CS_STAR4, CommandGroup::INSERT );
1966 implDescribeSupportedFeature( ".uno:StarShapes.star8" , SID_DRAWTBX_CS_STAR5, CommandGroup::INSERT );
1967 implDescribeSupportedFeature( ".uno:StarShapes.star12" , SID_DRAWTBX_CS_STAR6, CommandGroup::INSERT );
1968 implDescribeSupportedFeature( ".uno:StarShapes.star24" , SID_DRAWTBX_CS_STAR7, CommandGroup::INSERT );
1969 implDescribeSupportedFeature( ".uno:StarShapes.concave-star6" , SID_DRAWTBX_CS_STAR8, CommandGroup::INSERT );
1970 implDescribeSupportedFeature( ".uno:StarShapes.vertical-scroll" , SID_DRAWTBX_CS_STAR9, CommandGroup::INSERT );
1971 implDescribeSupportedFeature( ".uno:StarShapes.horizontal-scroll" , SID_DRAWTBX_CS_STAR10, CommandGroup::INSERT );
1972 implDescribeSupportedFeature( ".uno:StarShapes.signet" , SID_DRAWTBX_CS_STAR11, CommandGroup::INSERT );
1973 implDescribeSupportedFeature( ".uno:StarShapes.doorplate" , SID_DRAWTBX_CS_STAR12, CommandGroup::INSERT );
1975 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-process" , SID_DRAWTBX_CS_FLOWCHART1, CommandGroup::INSERT );
1976 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-alternate-process" , SID_DRAWTBX_CS_FLOWCHART2, CommandGroup::INSERT );
1977 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-decision" , SID_DRAWTBX_CS_FLOWCHART3, CommandGroup::INSERT );
1978 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-data" , SID_DRAWTBX_CS_FLOWCHART4, CommandGroup::INSERT );
1979 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-predefined-process" , SID_DRAWTBX_CS_FLOWCHART5, CommandGroup::INSERT );
1980 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-internal-storage" , SID_DRAWTBX_CS_FLOWCHART6, CommandGroup::INSERT );
1981 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-document" , SID_DRAWTBX_CS_FLOWCHART7, CommandGroup::INSERT );
1982 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-multidocument" , SID_DRAWTBX_CS_FLOWCHART8, CommandGroup::INSERT );
1983 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-terminator" , SID_DRAWTBX_CS_FLOWCHART9, CommandGroup::INSERT );
1984 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-preparation" , SID_DRAWTBX_CS_FLOWCHART10, CommandGroup::INSERT );
1985 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-input" , SID_DRAWTBX_CS_FLOWCHART11, CommandGroup::INSERT );
1986 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-manual-operation" , SID_DRAWTBX_CS_FLOWCHART12, CommandGroup::INSERT );
1987 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-connector" , SID_DRAWTBX_CS_FLOWCHART13, CommandGroup::INSERT );
1988 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-off-page-connector" , SID_DRAWTBX_CS_FLOWCHART14, CommandGroup::INSERT );
1989 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-card" , SID_DRAWTBX_CS_FLOWCHART15, CommandGroup::INSERT );
1990 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-punched-tape" , SID_DRAWTBX_CS_FLOWCHART16, CommandGroup::INSERT );
1991 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-summing-junction" , SID_DRAWTBX_CS_FLOWCHART17, CommandGroup::INSERT );
1992 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-or" , SID_DRAWTBX_CS_FLOWCHART18, CommandGroup::INSERT );
1993 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-collate" , SID_DRAWTBX_CS_FLOWCHART19, CommandGroup::INSERT );
1994 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sort" , SID_DRAWTBX_CS_FLOWCHART20, CommandGroup::INSERT );
1995 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-extract" , SID_DRAWTBX_CS_FLOWCHART21, CommandGroup::INSERT );
1996 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-merge" , SID_DRAWTBX_CS_FLOWCHART22, CommandGroup::INSERT );
1997 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-stored-data" , SID_DRAWTBX_CS_FLOWCHART23, CommandGroup::INSERT );
1998 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-delay" , SID_DRAWTBX_CS_FLOWCHART24, CommandGroup::INSERT );
1999 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-sequential-access" , SID_DRAWTBX_CS_FLOWCHART25, CommandGroup::INSERT );
2000 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-magnetic-disk" , SID_DRAWTBX_CS_FLOWCHART26, CommandGroup::INSERT );
2001 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-direct-access-storage",SID_DRAWTBX_CS_FLOWCHART27, CommandGroup::INSERT );
2002 implDescribeSupportedFeature( ".uno:FlowChartShapes.flowchart-display" , SID_DRAWTBX_CS_FLOWCHART28, CommandGroup::INSERT );
2004 implDescribeSupportedFeature( ".uno:CalloutShapes.rectangular-callout" , SID_DRAWTBX_CS_CALLOUT1, CommandGroup::INSERT );
2005 implDescribeSupportedFeature( ".uno:CalloutShapes.round-rectangular-callout" , SID_DRAWTBX_CS_CALLOUT2, CommandGroup::INSERT );
2006 implDescribeSupportedFeature( ".uno:CalloutShapes.round-callout" , SID_DRAWTBX_CS_CALLOUT3, CommandGroup::INSERT );
2007 implDescribeSupportedFeature( ".uno:CalloutShapes.cloud-callout" , SID_DRAWTBX_CS_CALLOUT4, CommandGroup::INSERT );
2008 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-1" , SID_DRAWTBX_CS_CALLOUT5, CommandGroup::INSERT );
2009 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-2" , SID_DRAWTBX_CS_CALLOUT6, CommandGroup::INSERT );
2010 implDescribeSupportedFeature( ".uno:CalloutShapes.line-callout-3" , SID_DRAWTBX_CS_CALLOUT7, CommandGroup::INSERT );
2012 implDescribeSupportedFeature( ".uno:ArrowShapes", SID_DRAWTBX_CS_ARROW, CommandGroup::INSERT );
2014 implDescribeSupportedFeature( ".uno:FlowChartShapes", SID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT );
2015 implDescribeSupportedFeature( ".uno:CalloutShapes", SID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT );
2016 implDescribeSupportedFeature( ".uno:StarShapes", SID_DRAWTBX_CS_STAR, CommandGroup::INSERT );
2019 // keys
2020 implDescribeSupportedFeature( ".uno:Escape", SID_ESCAPE);
2022 // internal one
2023 implDescribeSupportedFeature( ".uno:RPT_RPTHEADER_UNDO", SID_REPORTHEADER_WITHOUT_UNDO);
2024 implDescribeSupportedFeature( ".uno:RPT_RPTFOOTER_UNDO", SID_REPORTFOOTER_WITHOUT_UNDO);
2025 implDescribeSupportedFeature( ".uno:RPT_PGHEADER_UNDO", SID_PAGEHEADER_WITHOUT_UNDO);
2026 implDescribeSupportedFeature( ".uno:RPT_PGFOOTER_UNDO", SID_PAGEFOOTER_WITHOUT_UNDO);
2027 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER", SID_GROUPHEADER);
2028 implDescribeSupportedFeature( ".uno:SID_GROUPHEADER_WITHOUT_UNDO", SID_GROUPHEADER_WITHOUT_UNDO);
2029 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER", SID_GROUPFOOTER);
2030 implDescribeSupportedFeature( ".uno:SID_GROUPFOOTER_WITHOUT_UNDO", SID_GROUPFOOTER_WITHOUT_UNDO);
2031 implDescribeSupportedFeature( ".uno:SID_GROUP_REMOVE", SID_GROUP_REMOVE);
2032 implDescribeSupportedFeature( ".uno:SID_GROUP_APPEND", SID_GROUP_APPEND);
2033 implDescribeSupportedFeature( ".uno:SID_ADD_CONTROL_PAIR", SID_ADD_CONTROL_PAIR);
2034 implDescribeSupportedFeature( ".uno:SplitPosition", SID_SPLIT_POSITION);
2035 implDescribeSupportedFeature( ".uno:LastPropertyBrowserPage", SID_PROPERTYBROWSER_LAST_PAGE);
2036 implDescribeSupportedFeature( ".uno:Select", SID_SELECT);
2037 implDescribeSupportedFeature( ".uno:InsertFunction", SID_RPT_NEW_FUNCTION);
2038 implDescribeSupportedFeature( ".uno:NextMark", SID_NEXT_MARK);
2039 implDescribeSupportedFeature( ".uno:PrevMark", SID_PREV_MARK);
2040 implDescribeSupportedFeature( ".uno:TerminateInplaceActivation", SID_TERMINATE_INPLACEACTIVATION);
2041 implDescribeSupportedFeature( ".uno:SelectAllLabels", SID_SELECT_ALL_LABELS);
2042 implDescribeSupportedFeature( ".uno:SelectAllEdits", SID_SELECT_ALL_EDITS);
2043 implDescribeSupportedFeature( ".uno:CollapseSection", SID_COLLAPSE_SECTION);
2044 implDescribeSupportedFeature( ".uno:ExpandSection", SID_EXPAND_SECTION);
2045 implDescribeSupportedFeature( ".uno:GetUndoStrings", SID_GETUNDOSTRINGS);
2046 implDescribeSupportedFeature( ".uno:GetRedoStrings", SID_GETREDOSTRINGS);
2049 void OReportController::impl_onModifyChanged()
2053 if ( m_xReportDefinition.is() )
2054 m_xReportDefinition->setModified( impl_isModified() );
2055 DBSubComponentController::impl_onModifyChanged();
2057 catch(const uno::Exception&)
2059 DBG_UNHANDLED_EXCEPTION("reportdesign");
2063 void OReportController::onLoadedMenu(const Reference< frame::XLayoutManager >& _xLayoutManager)
2065 if ( !_xLayoutManager.is() )
2066 return;
2068 static const std::u16string_view s_sMenu[] = {
2069 u"private:resource/statusbar/statusbar"
2070 ,u"private:resource/toolbar/reportcontrols"
2071 ,u"private:resource/toolbar/drawbar"
2072 ,u"private:resource/toolbar/Formatting"
2073 ,u"private:resource/toolbar/alignmentbar"
2074 ,u"private:resource/toolbar/sectionalignmentbar"
2075 ,u"private:resource/toolbar/resizebar"
2076 ,u"private:resource/toolbar/sectionshrinkbar"
2078 for (const auto & i : s_sMenu)
2080 _xLayoutManager->createElement( OUString(i) );
2081 _xLayoutManager->requestElement( OUString(i) );
2085 void OReportController::notifyGroupSections(const ContainerEvent& _rEvent,bool _bShow)
2087 uno::Reference< report::XGroup> xGroup(_rEvent.Element,uno::UNO_QUERY);
2088 if ( !xGroup.is() )
2089 return;
2091 SolarMutexGuard aSolarGuard;
2092 ::osl::MutexGuard aGuard( getMutex() );
2093 sal_Int32 nGroupPos = 0;
2094 _rEvent.Accessor >>= nGroupPos;
2096 if ( _bShow )
2098 xGroup->addPropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2099 xGroup->addPropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2101 else
2103 xGroup->removePropertyChangeListener(PROPERTY_HEADERON, static_cast<XPropertyChangeListener*>(this));
2104 xGroup->removePropertyChangeListener(PROPERTY_FOOTERON, static_cast<XPropertyChangeListener*>(this));
2107 if ( xGroup->getHeaderOn() )
2109 groupChange(xGroup,PROPERTY_HEADERON,nGroupPos,_bShow);
2110 if (_bShow)
2112 m_pReportControllerObserver->AddSection(xGroup->getHeader());
2114 else
2116 m_pReportControllerObserver->RemoveSection(xGroup->getHeader());
2119 if ( xGroup->getFooterOn() )
2121 groupChange(xGroup,PROPERTY_FOOTERON,nGroupPos,_bShow);
2122 if (_bShow)
2124 m_pReportControllerObserver->AddSection(xGroup->getFooter());
2126 else
2128 m_pReportControllerObserver->RemoveSection(xGroup->getFooter());
2133 // ::container::XContainerListener
2134 void SAL_CALL OReportController::elementInserted( const ContainerEvent& _rEvent )
2136 notifyGroupSections(_rEvent,true);
2139 void SAL_CALL OReportController::elementRemoved( const ContainerEvent& _rEvent )
2141 notifyGroupSections(_rEvent,false);
2144 void SAL_CALL OReportController::elementReplaced( const ContainerEvent& /*_rEvent*/ )
2146 SolarMutexGuard aSolarGuard;
2147 ::osl::MutexGuard aGuard( getMutex() );
2148 OSL_FAIL("Not yet implemented!");
2151 void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEvent& evt )
2153 SolarMutexGuard aSolarGuard;
2154 ::osl::MutexGuard aGuard( getMutex() );
2157 bool bShow = false;
2158 evt.NewValue >>= bShow;
2159 if ( evt.Source == m_xReportDefinition )
2161 if ( evt.PropertyName == PROPERTY_REPORTHEADERON )
2163 const sal_uInt16 nPosition = m_xReportDefinition->getPageHeaderOn() ? 1 : 0;
2164 if ( bShow )
2166 getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER,nPosition);
2167 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportHeader());
2169 else
2171 getDesignView()->removeSection(nPosition);
2174 else if ( evt.PropertyName == PROPERTY_REPORTFOOTERON )
2176 sal_uInt16 nPosition = getDesignView()->getSectionCount();
2177 if ( m_xReportDefinition->getPageFooterOn() )
2178 --nPosition;
2179 if ( bShow )
2181 getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER,nPosition);
2182 m_pReportControllerObserver->AddSection(m_xReportDefinition->getReportFooter());
2184 else
2186 getDesignView()->removeSection(nPosition - 1);
2189 else if ( evt.PropertyName == PROPERTY_PAGEHEADERON )
2191 if ( bShow )
2193 getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER,0);
2194 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageHeader());
2196 else
2198 getDesignView()->removeSection(sal_uInt16(0));
2201 else if ( evt.PropertyName == PROPERTY_PAGEFOOTERON )
2203 if ( bShow )
2205 getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
2206 m_pReportControllerObserver->AddSection(m_xReportDefinition->getPageFooter());
2208 else
2210 getDesignView()->removeSection(getDesignView()->getSectionCount() - 1);
2213 else if ( evt.PropertyName == PROPERTY_COMMAND
2214 || evt.PropertyName == PROPERTY_COMMANDTYPE
2215 || evt.PropertyName == PROPERTY_ESCAPEPROCESSING
2216 || evt.PropertyName == PROPERTY_FILTER
2219 m_xColumns.clear();
2220 m_xHoldAlive.clear();
2221 InvalidateFeature(SID_FM_ADD_FIELD);
2222 if ( !getDesignView()->isAddFieldVisible() && isUiVisible() )
2223 getDesignView()->toggleAddField();
2225 /// TODO: check what we need to notify here TitleHelper
2226 /*else if ( evt.PropertyName.equals( PROPERTY_CAPTION ) )
2227 updateTitle();*/
2229 else
2231 uno::Reference< report::XGroup> xGroup(evt.Source,uno::UNO_QUERY);
2232 if ( xGroup.is() )
2234 sal_Int32 nGroupPos = getGroupPosition(xGroup);
2236 groupChange(xGroup,evt.PropertyName,nGroupPos,bShow);
2240 catch(const uno::Exception&)
2242 DBG_UNHANDLED_EXCEPTION("reportdesign");
2247 void SAL_CALL OReportController::disposing( const lang::EventObject& Source )
2249 // simply disambiguate
2250 OReportController_BASE::disposing(Source);
2254 static sal_uInt16 lcl_getNonVisibleGroupsBefore( const uno::Reference< report::XGroups>& _xGroups
2255 ,sal_Int32 _nGroupPos
2256 ,::std::function<bool(OGroupHelper *)> const & _pGroupMemberFunction)
2258 uno::Reference< report::XGroup> xGroup;
2259 sal_uInt16 nNonVisibleGroups = 0;
2260 sal_Int32 nCount = _xGroups->getCount();
2261 for( sal_Int32 i = 0; i < _nGroupPos && i < nCount; ++i)
2263 xGroup.set(_xGroups->getByIndex(i),uno::UNO_QUERY);
2264 OSL_ENSURE(xGroup.is(),"Group is NULL! -> GPF");
2265 OGroupHelper aGroupHelper(xGroup);
2266 if ( !_pGroupMemberFunction(&aGroupHelper) )
2267 ++nNonVisibleGroups;
2269 return nNonVisibleGroups;
2272 void OReportController::groupChange( const uno::Reference< report::XGroup>& _xGroup,std::u16string_view _sPropName,sal_Int32 _nGroupPos,bool _bShow)
2274 ::std::function<bool(OGroupHelper *)> pMemFun = ::std::mem_fn(&OGroupHelper::getHeaderOn);
2275 ::std::function<uno::Reference<report::XSection>(OGroupHelper *)> pMemFunSection = ::std::mem_fn(&OGroupHelper::getHeader);
2276 OUString sColor(DBGROUPHEADER);
2277 sal_uInt16 nPosition = 0;
2278 bool bHandle = false;
2279 if ( _sPropName == PROPERTY_HEADERON )
2281 nPosition = m_xReportDefinition->getPageHeaderOn() ? (m_xReportDefinition->getReportHeaderOn() ? 2 : 1) : (m_xReportDefinition->getReportHeaderOn() ? 1 : 0);
2282 nPosition += (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisibleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2283 bHandle = true;
2285 else if ( _sPropName == PROPERTY_FOOTERON )
2287 pMemFun = ::std::mem_fn(&OGroupHelper::getFooterOn);
2288 pMemFunSection = ::std::mem_fn(&OGroupHelper::getFooter);
2289 nPosition = getDesignView()->getSectionCount();
2291 if ( m_xReportDefinition->getPageFooterOn() )
2292 --nPosition;
2293 if ( m_xReportDefinition->getReportFooterOn() )
2294 --nPosition;
2295 sColor = DBGROUPFOOTER;
2296 nPosition -= (static_cast<sal_uInt16>(_nGroupPos) - lcl_getNonVisibleGroupsBefore(m_xReportDefinition->getGroups(),_nGroupPos,pMemFun));
2297 if ( !_bShow )
2298 --nPosition;
2299 bHandle = true;
2301 if ( bHandle )
2303 if ( _bShow )
2305 OGroupHelper aGroupHelper(_xGroup);
2306 getDesignView()->addSection(pMemFunSection(&aGroupHelper),sColor,nPosition);
2308 else
2310 getDesignView()->removeSection(nPosition);
2315 IMPL_LINK_NOARG(OReportController, OnClipboardChanged, TransferableDataHelper*, void)
2317 OnInvalidateClipboard();
2320 void OReportController::OnInvalidateClipboard()
2322 InvalidateFeature(SID_CUT);
2323 InvalidateFeature(SID_COPY);
2324 InvalidateFeature(SID_PASTE);
2327 void OReportController::openPageDialog(const uno::Reference<report::XSection>& _xSection)
2329 if ( !m_xReportDefinition.is() )
2330 return;
2332 // UNO->ItemSet
2333 static SfxItemInfo aItemInfos[] =
2335 { SID_ATTR_LRSPACE, true },
2336 { SID_ATTR_ULSPACE, true },
2337 { SID_ATTR_PAGE, true },
2338 { SID_ATTR_PAGE_SIZE, true },
2339 { SID_ENUM_PAGE_MODE, true },
2340 { SID_PAPER_START, true },
2341 { SID_PAPER_END, true },
2342 { SID_ATTR_BRUSH, true },
2343 { XATTR_FILLSTYLE, true },
2344 { XATTR_FILLCOLOR, true },
2345 { XATTR_FILLGRADIENT, true },
2346 { XATTR_FILLHATCH, true },
2347 { XATTR_FILLBITMAP, true },
2348 { XATTR_FILLTRANSPARENCE, true },
2349 { XATTR_GRADIENTSTEPCOUNT, true },
2350 { XATTR_FILLBMP_TILE, true },
2351 { XATTR_FILLBMP_POS, true },
2352 { XATTR_FILLBMP_SIZEX, true },
2353 { XATTR_FILLBMP_SIZEY, true },
2354 { XATTR_FILLFLOATTRANSPARENCE, true },
2355 { XATTR_SECONDARYFILLCOLOR, true },
2356 { XATTR_FILLBMP_SIZELOG, true },
2357 { XATTR_FILLBMP_TILEOFFSETX, true },
2358 { XATTR_FILLBMP_TILEOFFSETY, true },
2359 { XATTR_FILLBMP_STRETCH, true },
2360 { XATTR_FILLBMP_POSOFFSETX, true },
2361 { XATTR_FILLBMP_POSOFFSETY, true },
2362 { XATTR_FILLBACKGROUND, true },
2363 { SID_ATTR_METRIC, true }
2366 MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
2367 FieldUnit eUserMetric = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH;
2368 static const WhichRangesContainer pRanges(svl::Items<
2369 RPTUI_ID_LRSPACE, XATTR_FILL_LAST,
2370 SID_ATTR_METRIC,SID_ATTR_METRIC
2372 rtl::Reference<SfxItemPool> pPool( new SfxItemPool("ReportPageProperties", RPTUI_ID_LRSPACE, RPTUI_ID_METRIC, aItemInfos ) );
2374 const Graphic aNullGraphic;
2375 const ::Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
2376 const ::Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
2377 const XGradient aNullGrad(COL_BLACK, COL_WHITE);
2378 const XHatch aNullHatch(aNullLineCol);
2380 std::vector<SfxPoolItem*> pDefaults
2382 new SvxLRSpaceItem(RPTUI_ID_LRSPACE),
2383 new SvxULSpaceItem(RPTUI_ID_ULSPACE),
2384 new SvxPageItem(RPTUI_ID_PAGE),
2385 new SvxSizeItem(RPTUI_ID_SIZE),
2386 new SfxUInt16Item(RPTUI_ID_PAGE_MODE,SVX_PAGE_MODE_STANDARD),
2387 new SfxUInt16Item(RPTUI_ID_START,PAPER_A4),
2388 new SfxUInt16Item(RPTUI_ID_END,PAPER_E),
2389 new SvxBrushItem(RPTUI_ID_BRUSH),
2390 new XFillStyleItem,
2391 new XFillColorItem("", aNullFillCol),
2392 new XFillGradientItem(aNullGrad),
2393 new XFillHatchItem(aNullHatch),
2394 new XFillBitmapItem(aNullGraphic),
2395 new XFillTransparenceItem,
2396 new XGradientStepCountItem,
2397 new XFillBmpTileItem,
2398 new XFillBmpPosItem,
2399 new XFillBmpSizeXItem,
2400 new XFillBmpSizeYItem,
2401 new XFillFloatTransparenceItem(aNullGrad, false),
2402 new XSecondaryFillColorItem("", aNullFillCol),
2403 new XFillBmpSizeLogItem,
2404 new XFillBmpTileOffsetXItem,
2405 new XFillBmpTileOffsetYItem,
2406 new XFillBmpStretchItem,
2407 new XFillBmpPosOffsetXItem,
2408 new XFillBmpPosOffsetYItem,
2409 new XFillBackgroundItem,
2410 new SfxUInt16Item(RPTUI_ID_METRIC,static_cast<sal_uInt16>(eUserMetric))
2413 pPool->SetDefaults(&pDefaults);
2416 pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
2417 pPool->FreezeIdRanges(); // the same
2421 SfxItemSet aDescriptor(*pPool, pRanges);
2422 // fill it
2423 if ( _xSection.is() )
2424 aDescriptor.Put(SvxBrushItem(::Color(ColorTransparency, _xSection->getBackColor()),RPTUI_ID_BRUSH));
2425 else
2427 aDescriptor.Put(SvxSizeItem(RPTUI_ID_SIZE,VCLSize(getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE))));
2428 aDescriptor.Put(SvxLRSpaceItem(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN)
2429 ,getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN),0,0,RPTUI_ID_LRSPACE));
2430 aDescriptor.Put(SvxULSpaceItem(static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_TOPMARGIN))
2431 ,static_cast<sal_uInt16>(getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BOTTOMMARGIN)),RPTUI_ID_ULSPACE));
2432 aDescriptor.Put(SfxUInt16Item(SID_ATTR_METRIC,static_cast<sal_uInt16>(eUserMetric)));
2434 uno::Reference< style::XStyle> xPageStyle(getUsedStyle(m_xReportDefinition));
2435 if ( xPageStyle.is() )
2437 SvxPageItem aPageItem(RPTUI_ID_PAGE);
2438 aPageItem.SetDescName(xPageStyle->getName());
2439 uno::Reference<beans::XPropertySet> xProp(xPageStyle,uno::UNO_QUERY_THROW);
2440 aPageItem.PutValue(xProp->getPropertyValue(PROPERTY_PAGESTYLELAYOUT),MID_PAGE_LAYOUT);
2441 aPageItem.SetLandscape(getStyleProperty<bool>(m_xReportDefinition,PROPERTY_ISLANDSCAPE));
2442 aPageItem.SetNumType(static_cast<SvxNumType>(getStyleProperty<sal_Int16>(m_xReportDefinition,PROPERTY_NUMBERINGTYPE)));
2443 aDescriptor.Put(aPageItem);
2444 aDescriptor.Put(SvxBrushItem(::Color(ColorTransparency, getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_BACKCOLOR)),RPTUI_ID_BRUSH));
2448 { // want the dialog to be destroyed before our set
2449 ORptPageDialog aDlg(
2450 getFrameWeld(), &aDescriptor,_xSection.is()
2451 ? OUString("BackgroundDialog")
2452 : OUString("PageDialog"));
2453 if (aDlg.run() == RET_OK)
2456 // ItemSet->UNO
2457 // UNO-properties
2458 const SfxItemSet* pSet = aDlg.GetOutputItemSet();
2459 if ( _xSection.is() )
2461 const SfxPoolItem* pItem;
2462 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
2463 _xSection->setBackColor(sal_Int32(static_cast<const SvxBrushItem*>(pItem)->GetColor()));
2465 else
2467 uno::Reference< beans::XPropertySet> xProp(getUsedStyle(m_xReportDefinition),uno::UNO_QUERY_THROW);
2468 const OUString sUndoAction(RptResId(RID_STR_UNDO_CHANGEPAGE));
2469 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2470 const SfxPoolItem* pItem = nullptr;
2471 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_SIZE,true,&pItem))
2473 uno::Any aValue;
2474 static_cast<const SvxSizeItem*>(pItem)->QueryValue(aValue);
2475 xProp->setPropertyValue(PROPERTY_PAPERSIZE,aValue);
2476 resetZoomType();
2479 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_LRSPACE,true,&pItem))
2481 Any aValue;
2482 static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_L_MARGIN);
2483 xProp->setPropertyValue(PROPERTY_LEFTMARGIN,aValue);
2484 static_cast<const SvxLRSpaceItem*>(pItem)->QueryValue(aValue,MID_R_MARGIN);
2485 xProp->setPropertyValue(PROPERTY_RIGHTMARGIN,aValue);
2487 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_ULSPACE,true,&pItem))
2489 xProp->setPropertyValue(PROPERTY_TOPMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetUpper()));
2490 xProp->setPropertyValue(PROPERTY_BOTTOMMARGIN,uno::makeAny(static_cast<const SvxULSpaceItem*>(pItem)->GetLower()));
2492 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_PAGE,true,&pItem))
2494 const SvxPageItem* pPageItem = static_cast<const SvxPageItem*>(pItem);
2495 xProp->setPropertyValue(PROPERTY_ISLANDSCAPE,uno::makeAny(pPageItem->IsLandscape()));
2496 xProp->setPropertyValue(PROPERTY_NUMBERINGTYPE,uno::makeAny(static_cast<sal_Int16>(pPageItem->GetNumType())));
2497 uno::Any aValue;
2498 pPageItem->QueryValue(aValue,MID_PAGE_LAYOUT);
2499 xProp->setPropertyValue(PROPERTY_PAGESTYLELAYOUT,aValue);
2500 resetZoomType();
2502 if ( SfxItemState::SET == pSet->GetItemState( RPTUI_ID_BRUSH,true,&pItem))
2504 ::Color aBackColor = static_cast<const SvxBrushItem*>(pItem)->GetColor();
2505 xProp->setPropertyValue(PROPERTY_BACKTRANSPARENT,uno::makeAny(aBackColor == COL_TRANSPARENT));
2506 xProp->setPropertyValue(PROPERTY_BACKCOLOR,uno::makeAny(aBackColor));
2512 catch(const Exception&)
2514 DBG_UNHANDLED_EXCEPTION("reportdesign");
2516 pPool.clear();
2518 for (SfxPoolItem* pDefault : pDefaults)
2519 delete pDefault;
2524 sal_Bool SAL_CALL OReportController::attachModel(const uno::Reference< frame::XModel > & xModel)
2526 ::osl::MutexGuard aGuard( getMutex() );
2528 uno::Reference< report::XReportDefinition > xReportDefinition( xModel, UNO_QUERY );
2529 if ( !xReportDefinition.is() )
2530 return false;
2532 uno::Reference< document::XUndoManagerSupplier > xTestSuppUndo( xModel, UNO_QUERY );
2533 if ( !xTestSuppUndo.is() )
2534 return false;
2536 m_xReportDefinition = xReportDefinition;
2537 return true;
2541 void OReportController::openSortingAndGroupingDialog()
2543 if ( !m_xReportDefinition.is() )
2544 return;
2545 if (!m_xGroupsFloater)
2547 m_xGroupsFloater = std::make_shared<OGroupsSortingDialog>(getFrameWeld(), !isEditable(), this);
2548 SvtViewOptions aDlgOpt(EViewType::Window, OStringToOUString(m_xGroupsFloater->get_help_id(), RTL_TEXTENCODING_UTF8));
2549 if ( aDlgOpt.Exists() )
2550 m_xGroupsFloater->getDialog()->set_window_state(OUStringToOString(aDlgOpt.GetWindowState(), RTL_TEXTENCODING_ASCII_US));
2552 if (isUiVisible())
2554 if (!m_xGroupsFloater->getDialog()->get_visible())
2555 weld::DialogController::runAsync(m_xGroupsFloater, [this](sal_Int32 /*nResult*/) { m_xGroupsFloater.reset(); });
2556 else
2557 m_xGroupsFloater->response(RET_CANCEL);
2561 sal_Int32 OReportController::getGroupPosition(const uno::Reference< report::XGroup >& _xGroup)
2563 return rptui::getPositionInIndexAccess(m_xReportDefinition->getGroups(),_xGroup);
2567 void OReportController::Notify(SfxBroadcaster & /* _rBc */, SfxHint const & _rHint)
2569 const DlgEdHint* pDlgEdHint = dynamic_cast<const DlgEdHint*>(&_rHint);
2570 if (!(pDlgEdHint && pDlgEdHint->GetKind() == RPTUI_HINT_SELECTIONCHANGED))
2571 return;
2573 const sal_Int32 nSelectionCount = getDesignView()->getMarkedObjectCount();
2574 if ( m_nSelectionCount != nSelectionCount )
2576 m_nSelectionCount = nSelectionCount;
2577 InvalidateAll();
2579 lang::EventObject aEvent(*this);
2580 m_aSelectionListeners.forEach<view::XSelectionChangeListener>(
2581 [&aEvent] (uno::Reference<view::XSelectionChangeListener> const& xListener) {
2582 return xListener->selectionChanged(aEvent);
2586 void OReportController::executeMethodWithUndo(TranslateId pUndoStrId,const ::std::function<void(ODesignView *)>& _pMemfun)
2588 const OUString sUndoAction = RptResId(pUndoStrId);
2589 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2590 _pMemfun( getDesignView() );
2591 InvalidateFeature( SID_UNDO );
2594 void OReportController::alignControlsWithUndo(TranslateId pUndoStrId, ControlModification _nControlModification, bool _bAlignAtSection)
2596 const OUString sUndoAction = RptResId(pUndoStrId);
2597 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2598 getDesignView()->alignMarkedObjects(_nControlModification,_bAlignAtSection);
2599 InvalidateFeature( SID_UNDO );
2602 void OReportController::shrinkSectionBottom(const uno::Reference<report::XSection>& _xSection)
2604 const sal_Int32 nElements = _xSection->getCount();
2605 if (nElements == 0)
2607 // there are no elements
2608 return;
2610 const sal_Int32 nSectionHeight = _xSection->getHeight();
2611 sal_Int32 nMaxPositionY = 0;
2612 uno::Reference< report::XReportComponent> xReportComponent;
2614 // for every component get its Y-position and compare it to the current Y-position
2615 for (int i=0;i<nElements;i++)
2617 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2618 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2619 const sal_Int32 nReportComponentHeight = xReportComponent->getHeight();
2620 const sal_Int32 nReportComponentPositionYAndHeight = nReportComponentPositionY + nReportComponentHeight;
2621 nMaxPositionY = std::max(nReportComponentPositionYAndHeight, nMaxPositionY);
2623 // now we know the minimal Y-Position and maximal Y-Position
2625 if (nMaxPositionY > (nSectionHeight - 7) ) // Magic Number, we use a little bit less heights for right positioning
2627 // the lowest position is already 0
2628 return;
2630 _xSection->setHeight(nMaxPositionY);
2633 void OReportController::shrinkSectionTop(const uno::Reference<report::XSection>& _xSection)
2635 const sal_Int32 nElements = _xSection->getCount();
2636 if (nElements == 0)
2638 // there are no elements
2639 return;
2642 const sal_Int32 nSectionHeight = _xSection->getHeight();
2643 sal_Int32 nMinPositionY = nSectionHeight;
2644 uno::Reference< report::XReportComponent> xReportComponent;
2646 // for every component get its Y-position and compare it to the current Y-position
2647 for (int i=0;i<nElements;i++)
2649 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2650 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2651 nMinPositionY = std::min(nReportComponentPositionY, nMinPositionY);
2653 // now we know the minimal Y-Position and maximal Y-Position
2654 if (nMinPositionY == 0)
2656 // the lowest position is already 0
2657 return;
2659 for (int i=0;i<nElements;i++)
2661 xReportComponent.set(_xSection->getByIndex(i), uno::UNO_QUERY);
2662 const sal_Int32 nReportComponentPositionY = xReportComponent->getPositionY();
2663 const sal_Int32 nNewPositionY = nReportComponentPositionY - nMinPositionY;
2664 xReportComponent->setPositionY(nNewPositionY);
2666 const sal_Int32 nNewSectionHeight = nSectionHeight - nMinPositionY;
2667 _xSection->setHeight(nNewSectionHeight);
2670 void OReportController::shrinkSection(TranslateId pUndoStrId, const uno::Reference<report::XSection>& _xSection, sal_Int32 _nSid)
2672 if ( _xSection.is() )
2674 const OUString sUndoAction = RptResId(pUndoStrId);
2675 UndoContext aUndoContext( getUndoManager(), sUndoAction );
2677 if (_nSid == SID_SECTION_SHRINK)
2679 shrinkSectionTop(_xSection);
2680 shrinkSectionBottom(_xSection);
2682 else if (_nSid == SID_SECTION_SHRINK_TOP)
2684 shrinkSectionTop(_xSection);
2686 else if (_nSid == SID_SECTION_SHRINK_BOTTOM)
2688 shrinkSectionBottom(_xSection);
2692 InvalidateFeature( SID_UNDO );
2696 uno::Any SAL_CALL OReportController::getViewData()
2698 ::osl::MutexGuard aGuard( getMutex() );
2700 const sal_Int32 nCommandIDs[] =
2702 SID_GRID_VISIBLE,
2703 SID_GRID_USE,
2704 SID_HELPLINES_MOVE,
2705 SID_RULER,
2706 SID_SHOW_PROPERTYBROWSER,
2707 SID_PROPERTYBROWSER_LAST_PAGE,
2708 SID_SPLIT_POSITION
2711 ::comphelper::NamedValueCollection aCommandProperties;
2712 for (sal_Int32 nCommandID : nCommandIDs)
2714 const FeatureState aFeatureState = GetState( nCommandID );
2716 OUString sCommandURL( getURLForId( nCommandID ).Main );
2717 OSL_ENSURE( sCommandURL.startsWith( ".uno:" ), "OReportController::getViewData: illegal command URL!" );
2718 sCommandURL = sCommandURL.copy( 5 );
2720 Any aCommandState;
2721 if ( !!aFeatureState.bChecked )
2722 aCommandState <<= *aFeatureState.bChecked;
2723 else if ( aFeatureState.aValue.hasValue() )
2724 aCommandState = aFeatureState.aValue;
2726 aCommandProperties.put( sCommandURL, aCommandState );
2729 ::comphelper::NamedValueCollection aViewData;
2730 aViewData.put( "CommandProperties", aCommandProperties.getPropertyValues() );
2732 if ( getDesignView() )
2734 ::std::vector<sal_uInt16> aCollapsedPositions;
2735 getDesignView()->fillCollapsedSections(aCollapsedPositions);
2736 if ( !aCollapsedPositions.empty() )
2738 uno::Sequence<beans::PropertyValue> aCollapsedSections(aCollapsedPositions.size());
2739 beans::PropertyValue* pCollapsedIter = aCollapsedSections.getArray();
2740 sal_Int32 i = 1;
2741 for (const auto& rPos : aCollapsedPositions)
2743 pCollapsedIter->Name = PROPERTY_SECTION + OUString::number(i);
2744 pCollapsedIter->Value <<= static_cast<sal_Int32>(rPos);
2745 ++pCollapsedIter;
2746 ++i;
2749 aViewData.put( "CollapsedSections", aCollapsedSections );
2752 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
2753 if ( pSectionWindow )
2755 aViewData.put( "MarkedSection", static_cast<sal_Int32>(pSectionWindow->getReportSection().getPage()->GetPageNum()) );
2759 aViewData.put( "ZoomFactor", m_nZoomValue );
2760 return uno::makeAny( aViewData.getPropertyValues() );
2763 void SAL_CALL OReportController::restoreViewData(const uno::Any& i_data)
2765 ::osl::MutexGuard aGuard( getMutex() );
2769 const ::comphelper::NamedValueCollection aViewData( i_data );
2771 m_aCollapsedSections = aViewData.getOrDefault( "CollapsedSections", m_aCollapsedSections );
2772 m_nPageNum = aViewData.getOrDefault( "MarkedSection", m_nPageNum );
2773 m_nZoomValue = aViewData.getOrDefault( "ZoomFactor", m_nZoomValue );
2774 // TODO: setting those 3 members is not enough - in theory, restoreViewData can be called when the
2775 // view is fully alive, so we need to reflect those 3 values in the view.
2776 // (At the moment, the method is called only during construction phase)
2779 ::comphelper::NamedValueCollection aCommandProperties( aViewData.get( "CommandProperties" ) );
2780 const ::std::vector< OUString > aCommandNames( aCommandProperties.getNames() );
2782 for ( const auto& rCommandName : aCommandNames )
2784 const Any& rCommandValue = aCommandProperties.get( rCommandName );
2785 if ( !rCommandValue.hasValue() )
2786 continue;
2788 if ( getView() )
2790 util::URL aCommand;
2791 aCommand.Complete = ".uno:" + rCommandName;
2793 Sequence aCommandArgs{ comphelper::makePropertyValue("Value", rCommandValue) };
2794 executeUnChecked( aCommand, aCommandArgs );
2796 else
2798 if ( rCommandName == "ShowRuler" )
2799 OSL_VERIFY( rCommandValue >>= m_bShowRuler );
2800 else if ( rCommandName == "HelplinesMove" )
2801 OSL_VERIFY( rCommandValue >>= m_bHelplinesMove );
2802 else if ( rCommandName == "GridVisible" )
2803 OSL_VERIFY( rCommandValue >>= m_bGridVisible );
2804 else if ( rCommandName == "GridUse" )
2805 OSL_VERIFY( rCommandValue >>= m_bGridUse );
2806 else if ( rCommandName == "ControlProperties" )
2807 OSL_VERIFY( rCommandValue >>= m_bShowProperties );
2808 else if ( rCommandName == "LastPropertyBrowserPage" )
2809 OSL_VERIFY( rCommandValue >>= m_sLastActivePage );
2810 else if ( rCommandName == "SplitPosition" )
2811 OSL_VERIFY( rCommandValue >>= m_nSplitPos );
2815 catch(const IllegalArgumentException&)
2817 DBG_UNHANDLED_EXCEPTION("reportdesign");
2821 Reference<XFrame> OReportController::getXFrame()
2823 if ( !m_xFrameLoader.is() )
2825 m_xFrameLoader.set( frame::Desktop::create(m_xContext) );
2827 const sal_Int32 nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
2828 Reference<XFrame> xFrame = m_xFrameLoader->findFrame("_blank",nFrameSearchFlag);
2829 return xFrame;
2833 uno::Reference<frame::XModel> OReportController::executeReport()
2835 OSL_ENSURE(m_xReportDefinition.is(),"Where is my report?");
2837 uno::Reference<frame::XModel> xModel;
2838 if ( m_xReportDefinition.is() )
2840 TranslateId pErrorId = RID_ERR_NO_COMMAND;
2841 bool bEnabled = !m_xReportDefinition->getCommand().isEmpty();
2842 if ( bEnabled )
2844 bEnabled = false;
2845 const sal_uInt16 nCount = m_aReportModel->GetPageCount();
2846 sal_uInt16 i = 0;
2847 for (; i < nCount && !bEnabled ; ++i)
2849 const SdrPage* pPage = m_aReportModel->GetPage(i);
2850 bEnabled = pPage->GetObjCount() != 0;
2852 if ( !bEnabled )
2853 pErrorId = RID_ERR_NO_OBJECTS;
2856 dbtools::SQLExceptionInfo aInfo;
2857 if ( !bEnabled )
2859 sdb::SQLContext aFirstMessage;
2860 OUString sInfo = RptResId( pErrorId );
2861 aFirstMessage.Message = sInfo;
2862 aInfo = aFirstMessage;
2863 if ( isEditable() )
2865 sal_uInt16 nCommand = 0;
2866 if (pErrorId != RID_ERR_NO_COMMAND)
2868 if ( !m_bShowProperties )
2869 executeUnChecked(SID_SHOW_PROPERTYBROWSER,uno::Sequence< beans::PropertyValue>());
2871 m_sLastActivePage = "Data";
2872 getDesignView()->setCurrentPage(m_sLastActivePage);
2873 nCommand = SID_SELECT_REPORT;
2875 else if ( getDesignView() && !getDesignView()->isAddFieldVisible() )
2877 nCommand = SID_FM_ADD_FIELD;
2879 if ( nCommand )
2881 uno::Sequence< beans::PropertyValue> aArgs;
2882 executeUnChecked(nCommand,aArgs);
2886 else
2888 m_bInGeneratePreview = true;
2891 weld::WaitObject aWait(getFrameWeld()); // cursor
2892 if ( !m_xReportEngine.is() )
2893 m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
2894 m_xReportEngine->setReportDefinition(m_xReportDefinition);
2895 m_xReportEngine->setActiveConnection(getConnection());
2896 Reference<XFrame> xFrame = getXFrame();
2897 xModel = m_xReportEngine->createDocumentAlive(xFrame);
2899 catch(const sdbc::SQLException&)
2900 { // SQLExceptions and derived exceptions must not be translated
2901 aInfo = ::cppu::getCaughtException();
2903 catch(const uno::Exception& e)
2905 uno::Any aCaughtException( ::cppu::getCaughtException() );
2907 // our first message says: we caught an exception
2908 sdb::SQLContext aFirstMessage;
2909 OUString sInfo(RptResId(RID_STR_CAUGHT_FOREIGN_EXCEPTION));
2910 sInfo = sInfo.replaceAll("$type$", aCaughtException.getValueTypeName());
2911 aFirstMessage.Message = sInfo;
2913 // our second message: the message of the exception we caught
2914 sdbc::SQLException aSecondMessage;
2915 aSecondMessage.Message = e.Message;
2916 aSecondMessage.Context = e.Context;
2918 // maybe our third message: the message which is wrapped in the exception we caught
2919 sdbc::SQLException aThirdMessage;
2920 lang::WrappedTargetException aWrapped;
2921 if ( aCaughtException >>= aWrapped )
2923 aThirdMessage.Message = aWrapped.Message;
2924 aThirdMessage.Context = aWrapped.Context;
2927 if ( !aThirdMessage.Message.isEmpty() )
2928 aSecondMessage.NextException <<= aThirdMessage;
2929 aFirstMessage.NextException <<= aSecondMessage;
2931 aInfo = aFirstMessage;
2933 if (aInfo.isValid())
2935 const OUString suSQLContext = RptResId( RID_STR_COULD_NOT_CREATE_REPORT );
2936 aInfo.prepend(suSQLContext);
2938 m_bInGeneratePreview = false;
2941 if (aInfo.isValid())
2943 showError(aInfo);
2946 return xModel;
2949 uno::Reference< frame::XModel > SAL_CALL OReportController::getModel()
2951 return m_xReportDefinition;
2954 uno::Reference< sdbc::XRowSet > const & OReportController::getRowSet()
2956 OSL_PRECOND( m_xReportDefinition.is(), "OReportController::getRowSet: no report definition?!" );
2958 if ( m_xRowSet.is() || !m_xReportDefinition.is() )
2959 return m_xRowSet;
2963 uno::Reference< sdbc::XRowSet > xRowSet(
2964 getORB()->getServiceManager()->createInstanceWithContext("com.sun.star.sdb.RowSet", getORB()),
2965 uno::UNO_QUERY );
2966 uno::Reference< beans::XPropertySet> xRowSetProp( xRowSet, uno::UNO_QUERY_THROW );
2968 xRowSetProp->setPropertyValue( PROPERTY_ACTIVECONNECTION, uno::makeAny( getConnection() ) );
2969 xRowSetProp->setPropertyValue( PROPERTY_APPLYFILTER, uno::makeAny( true ) );
2971 auto aNoConverter = std::make_shared<AnyConverter>();
2972 TPropertyNamePair aPropertyMediation;
2973 aPropertyMediation.emplace( PROPERTY_COMMAND, TPropertyConverter(PROPERTY_COMMAND,aNoConverter) );
2974 aPropertyMediation.emplace( PROPERTY_COMMANDTYPE, TPropertyConverter(PROPERTY_COMMANDTYPE,aNoConverter) );
2975 aPropertyMediation.emplace( PROPERTY_ESCAPEPROCESSING, TPropertyConverter(PROPERTY_ESCAPEPROCESSING,aNoConverter) );
2976 aPropertyMediation.emplace( PROPERTY_FILTER, TPropertyConverter(PROPERTY_FILTER,aNoConverter) );
2978 m_xRowSetMediator = new OPropertyMediator( m_xReportDefinition, xRowSetProp, std::move(aPropertyMediation) );
2979 m_xRowSet = xRowSet;
2981 catch(const uno::Exception&)
2983 DBG_UNHANDLED_EXCEPTION("reportdesign");
2986 return m_xRowSet;
2989 void OReportController::insertGraphic()
2991 const OUString sTitle(RptResId(RID_STR_IMPORT_GRAPHIC));
2992 // build some arguments for the upcoming dialog
2995 uno::Reference< report::XSection> xSection = getDesignView()->getCurrentSection();
2996 ::sfx2::FileDialogHelper aDialog(ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW, FileDialogFlags::Graphic, getFrameWeld());
2997 aDialog.SetContext(sfx2::FileDialogHelper::ReportInsertImage);
2998 aDialog.SetTitle( sTitle );
3000 uno::Reference< ui::dialogs::XFilePickerControlAccess > xController(aDialog.GetFilePicker(), UNO_QUERY_THROW);
3001 xController->setValue(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, css::uno::Any(true));
3002 xController->enableControl(ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, false/*sal_True*/);
3003 xController->setValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, css::uno::Any(true) );
3005 if ( ERRCODE_NONE == aDialog.Execute() )
3007 bool bLink = true;
3008 xController->getValue( ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bLink;
3009 uno::Sequence<beans::PropertyValue> aArgs( comphelper::InitPropertySequence({
3010 { PROPERTY_IMAGEURL, Any(aDialog.GetPath()) },
3011 { PROPERTY_PRESERVEIRI, Any(bLink) }
3012 }));
3013 createControl(aArgs,xSection,OUString(),OBJ_RD_IMAGECONTROL);
3016 catch(const Exception&)
3018 DBG_UNHANDLED_EXCEPTION("reportdesign");
3023 sal_Bool SAL_CALL OReportController::select( const Any& aSelection )
3025 ::osl::MutexGuard aGuard( getMutex() );
3026 if ( getDesignView() )
3028 getDesignView()->unmarkAllObjects();
3029 getDesignView()->SetMode(DlgEdMode::Select);
3031 uno::Sequence< uno::Reference<report::XReportComponent> > aElements;
3032 if ( aSelection >>= aElements )
3034 if ( aElements.hasElements() )
3035 getDesignView()->showProperties(uno::Reference<uno::XInterface>(aElements[0],uno::UNO_QUERY));
3036 getDesignView()->setMarked(aElements, true);
3038 else
3040 uno::Reference<uno::XInterface> xObject(aSelection,uno::UNO_QUERY);
3041 uno::Reference<report::XReportComponent> xProp(xObject,uno::UNO_QUERY);
3042 if ( xProp.is() )
3044 getDesignView()->showProperties(xObject);
3045 aElements = { xProp };
3046 getDesignView()->setMarked(aElements, true);
3048 else
3050 uno::Reference<report::XSection> xSection(aSelection,uno::UNO_QUERY);
3051 if ( !xSection.is() && xObject.is() )
3052 getDesignView()->showProperties(xObject);
3053 getDesignView()->setMarked(xSection,xSection.is());
3056 InvalidateAll();
3058 return true;
3061 Any SAL_CALL OReportController::getSelection( )
3063 ::osl::MutexGuard aGuard( getMutex() );
3064 Any aRet;
3065 if ( getDesignView() )
3067 aRet = getDesignView()->getCurrentlyShownProperty();
3068 if ( !aRet.hasValue() )
3069 aRet <<= getDesignView()->getCurrentSection();
3071 return aRet;
3074 void SAL_CALL OReportController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& Listener )
3076 m_aSelectionListeners.addInterface( Listener );
3079 void SAL_CALL OReportController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& Listener )
3081 m_aSelectionListeners.removeInterface( Listener );
3084 void OReportController::createNewFunction(const uno::Any& _aValue)
3086 uno::Reference< container::XIndexContainer> xFunctions(_aValue,uno::UNO_QUERY_THROW);
3087 const OUString sNewName = RptResId(RID_STR_FUNCTION);
3088 uno::Reference< report::XFunction> xFunction(report::Function::create(m_xContext));
3089 xFunction->setName(sNewName);
3090 // the call below will also create an undo action -> listener
3091 xFunctions->insertByIndex(xFunctions->getCount(),uno::makeAny(xFunction));
3094 IMPL_LINK_NOARG( OReportController, OnExecuteReport, void*, void )
3096 executeReport();
3099 void OReportController::createControl(const Sequence< PropertyValue >& _aArgs,const uno::Reference< report::XSection>& _xSection,const OUString& _sFunction,SdrObjKind _nObjectId)
3101 SequenceAsHashMap aMap(_aArgs);
3102 getDesignView()->setMarked(_xSection, true);
3103 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
3104 if ( !pSectionWindow )
3105 return;
3107 OSL_ENSURE(pSectionWindow->getReportSection().getSection() == _xSection,"Invalid section after marking the correct one.");
3109 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3110 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3111 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3112 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3113 if ( aPos.X < nLeftMargin )
3114 aPos.X = nLeftMargin;
3116 SdrObject* pNewControl = nullptr;
3117 uno::Reference< report::XReportComponent> xShapeProp;
3118 if ( _nObjectId == OBJ_CUSTOMSHAPE )
3120 pNewControl = SdrObjFactory::MakeNewObject(
3121 *m_aReportModel,
3122 SdrInventor::ReportDesign,
3123 _nObjectId);
3124 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY);
3125 OUString sCustomShapeType = getDesignView()->GetInsertObjString();
3126 if ( sCustomShapeType.isEmpty() )
3127 sCustomShapeType = "diamond";
3128 OReportSection::createDefault(sCustomShapeType,pNewControl);
3129 pNewControl->SetLogicRect(tools::Rectangle(3000,500,6000,3500)); // switch height and width
3131 else if ( _nObjectId == OBJ_OLE2 || OBJ_RD_SUBREPORT == _nObjectId )
3133 pNewControl = SdrObjFactory::MakeNewObject(
3134 *m_aReportModel,
3135 SdrInventor::ReportDesign,
3136 _nObjectId);
3138 pNewControl->SetLogicRect(tools::Rectangle(3000,500,8000,5500)); // switch height and width
3139 xShapeProp.set(pNewControl->getUnoShape(),uno::UNO_QUERY_THROW);
3140 OOle2Obj* pObj = dynamic_cast<OOle2Obj*>(pNewControl);
3141 if ( pObj && !pObj->IsEmpty() )
3143 pObj->initializeChart(getModel());
3146 else
3148 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pLabel;
3149 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl;
3151 FmFormView::createControlLabelPair(
3152 getDesignView()->GetOutDev(),
3153 nLeftMargin,
3155 nullptr,
3156 nullptr,
3157 _nObjectId,
3158 SdrInventor::ReportDesign,
3159 OBJ_RD_FIXEDTEXT,
3161 // tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
3162 // m_aReportModel seems pretty safe, it's done in other places, initialized
3163 // in impl_initialize and throws a RuntimeException if not existing.
3164 *m_aReportModel,
3166 pLabel,
3167 pControl);
3169 pLabel.reset();
3171 pNewControl = pControl.release();
3172 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pNewControl);
3173 assert(pObj);
3174 if(pObj)
3176 uno::Reference<beans::XPropertySet> xUnoProp(pObj->GetUnoControlModel(),uno::UNO_QUERY);
3177 xShapeProp.set(pObj->getUnoShape(),uno::UNO_QUERY);
3178 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3179 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3181 const OUString sProps[] = { OUString(PROPERTY_NAME)
3182 ,OUString(PROPERTY_FONTDESCRIPTOR)
3183 ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
3184 ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
3185 ,OUString(PROPERTY_ORIENTATION)
3186 ,OUString(PROPERTY_BORDER)
3187 ,OUString(PROPERTY_FORMATSSUPPLIER)
3188 ,OUString(PROPERTY_BACKGROUNDCOLOR)
3190 for(const auto & sProp : sProps)
3192 if ( xInfo->hasPropertyByName(sProp) && xShapeInfo->hasPropertyByName(sProp) )
3193 xUnoProp->setPropertyValue(sProp,xShapeProp->getPropertyValue(sProp));
3196 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3197 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3200 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) && !_sFunction.isEmpty() )
3202 ReportFormula aFunctionFormula( ReportFormula::Expression, _sFunction );
3203 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFunctionFormula.getCompleteFormula() ) );
3206 sal_Int32 nFormatKey = aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEY,sal_Int32(0));
3207 if ( nFormatKey && xInfo->hasPropertyByName(PROPERTY_FORMATKEY) )
3208 xUnoProp->setPropertyValue( PROPERTY_FORMATKEY, uno::makeAny( nFormatKey ) );
3210 OUString sUrl = aMap.getUnpackedValueOrDefault(PROPERTY_IMAGEURL,OUString());
3211 if ( !sUrl.isEmpty() && xInfo->hasPropertyByName(PROPERTY_IMAGEURL) )
3212 xUnoProp->setPropertyValue( PROPERTY_IMAGEURL, uno::makeAny( sUrl ) );
3214 pObj->CreateMediator(true);
3216 if ( _nObjectId == OBJ_RD_FIXEDTEXT ) // special case for fixed text
3217 xUnoProp->setPropertyValue(PROPERTY_LABEL,uno::makeAny(OUnoObject::GetDefaultName(pObj)));
3218 else if ( _nObjectId == OBJ_RD_VFIXEDLINE )
3220 awt::Size aOlSize = xShapeProp->getSize();
3221 xShapeProp->setSize(awt::Size(aOlSize.Height,aOlSize.Width)); // switch height and width
3226 const sal_Int32 nShapeWidth = aMap.getUnpackedValueOrDefault(PROPERTY_WIDTH,xShapeProp->getWidth());
3227 if ( nShapeWidth != xShapeProp->getWidth() )
3228 xShapeProp->setWidth( nShapeWidth );
3230 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3231 if ( bChangedPos )
3232 aPos.X = nPaperWidth - nShapeWidth;
3233 xShapeProp->setPosition(aPos);
3235 correctOverlapping(pNewControl,pSectionWindow->getReportSection());
3238 void OReportController::createDateTime(const Sequence< PropertyValue >& _aArgs)
3240 getDesignView()->unmarkAllObjects();
3242 const OUString sUndoAction(RptResId(RID_STR_UNDO_INSERT_CONTROL));
3243 UndoContext aUndoContext( getUndoManager(), sUndoAction );
3245 SequenceAsHashMap aMap(_aArgs);
3246 aMap.createItemIfMissing(PROPERTY_FORMATKEY,aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYDATE,sal_Int32(0)));
3248 uno::Reference< report::XSection> xSection = aMap.getUnpackedValueOrDefault(PROPERTY_SECTION,uno::Reference< report::XSection>());
3249 OUString sFunction;
3251 bool bDate = aMap.getUnpackedValueOrDefault(PROPERTY_DATE_STATE, false);
3252 if ( bDate )
3254 sFunction = "TODAY()";
3255 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3257 bool bTime = aMap.getUnpackedValueOrDefault(PROPERTY_TIME_STATE, false);
3258 if ( bTime )
3260 sFunction = "TIMEVALUE(NOW())";
3261 aMap[PROPERTY_FORMATKEY] <<= aMap.getUnpackedValueOrDefault(PROPERTY_FORMATKEYTIME,sal_Int32(0));
3262 createControl(aMap.getAsConstPropertyValueList(),xSection,sFunction);
3266 void OReportController::createPageNumber(const Sequence< PropertyValue >& _aArgs)
3268 getDesignView()->unmarkAllObjects();
3270 const OUString sUndoAction(RptResId(RID_STR_UNDO_INSERT_CONTROL));
3271 UndoContext aUndoContext( getUndoManager(), sUndoAction );
3273 if ( !m_xReportDefinition->getPageHeaderOn() )
3275 uno::Sequence< beans::PropertyValue > aArgs;
3276 executeChecked(SID_PAGEHEADERFOOTER,aArgs);
3279 SequenceAsHashMap aMap(_aArgs);
3280 bool bStateOfPage = aMap.getUnpackedValueOrDefault(PROPERTY_STATE, false);
3282 OUString sFunction( RptResId(STR_RPT_PN_PAGE) );
3283 sFunction = sFunction.replaceFirst("#PAGENUMBER#", "PageNumber()");
3285 if ( bStateOfPage )
3287 sFunction += RptResId(STR_RPT_PN_PAGE_OF);
3288 sFunction = sFunction.replaceFirst("#PAGECOUNT#", "PageCount()");
3291 bool bInPageHeader = aMap.getUnpackedValueOrDefault(PROPERTY_PAGEHEADERON, true);
3292 createControl(_aArgs,bInPageHeader ? m_xReportDefinition->getPageHeader() : m_xReportDefinition->getPageFooter(),sFunction);
3296 void OReportController::addPairControls(const Sequence< PropertyValue >& aArgs)
3298 getDesignView()->unmarkAllObjects();
3300 // the FormatKey determines which field is required
3301 OSectionWindow* pSectionWindow[2];
3302 pSectionWindow[0] = getDesignView()->getMarkedSection();
3304 if ( !pSectionWindow[0] )
3306 select(uno::makeAny(m_xReportDefinition->getDetail()));
3307 pSectionWindow[0] = getDesignView()->getMarkedSection();
3308 if ( !pSectionWindow[0] )
3309 return;
3312 uno::Reference<report::XSection> xCurrentSection = getDesignView()->getCurrentSection();
3313 UndoContext aUndoContext(getUndoManager(), RptResId(RID_STR_UNDO_INSERT_CONTROL));
3317 bool bHandleOnlyOne = false;
3318 for(const PropertyValue& rArg : aArgs)
3320 if (bHandleOnlyOne)
3321 break;
3322 Sequence< PropertyValue > aValue;
3323 if ( !(rArg.Value >>= aValue) )
3324 { // the sequence has only one element which already contains the descriptor
3325 bHandleOnlyOne = true;
3326 aValue = aArgs;
3328 svx::ODataAccessDescriptor aDescriptor(aValue);
3329 SequenceAsHashMap aMap(aValue);
3330 uno::Reference<report::XSection> xSection = aMap.getUnpackedValueOrDefault("Section",xCurrentSection);
3331 uno::Reference<report::XReportDefinition> xReportDefinition = xSection->getReportDefinition();
3333 getDesignView()->setMarked(xSection, true);
3334 pSectionWindow[0] = getDesignView()->getMarkedSection();
3336 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_LEFTMARGIN);
3337 awt::Point aPos = aMap.getUnpackedValueOrDefault(PROPERTY_POSITION,awt::Point(nLeftMargin,0));
3338 if ( aPos.X < nLeftMargin )
3339 aPos.X = nLeftMargin;
3341 // LLA: new feature, add the Label in dependency of the given DND_ACTION one section up, normal or one section down
3342 sal_Int8 nDNDAction = aMap.getUnpackedValueOrDefault("DNDAction", sal_Int8(0));
3343 pSectionWindow[1] = pSectionWindow[0];
3344 bool bLabelAboveTextField = nDNDAction == DND_ACTION_COPY;
3345 if ( bLabelAboveTextField || nDNDAction == DND_ACTION_LINK )
3347 // Add the Label one Section up
3348 pSectionWindow[1] = getDesignView()->getMarkedSection(bLabelAboveTextField ? PREVIOUS : POST);
3349 if (!pSectionWindow[1])
3351 // maybe out of bounds
3352 pSectionWindow[1] = pSectionWindow[0];
3355 // clear all selections
3356 getDesignView()->unmarkAllObjects();
3358 uno::Reference< beans::XPropertySet > xField( aDescriptor[ svx::DataAccessDescriptorProperty::ColumnObject ], uno::UNO_QUERY );
3359 uno::Reference< lang::XComponent > xHoldAlive;
3360 if ( !xField.is() )
3362 OUString sCommand;
3363 OUString sColumnName;
3364 sal_Int32 nCommandType( -1 );
3365 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::Command ] >>= sCommand );
3366 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::ColumnName ] >>= sColumnName );
3367 OSL_VERIFY( aDescriptor[ svx::DataAccessDescriptorProperty::CommandType ] >>= nCommandType );
3369 uno::Reference< container::XNameAccess > xColumns;
3370 uno::Reference< sdbc::XConnection > xConnection( getConnection() );
3371 if ( !sCommand.isEmpty() && nCommandType != -1 && !sColumnName.isEmpty() && xConnection.is() )
3373 if ( xReportDefinition->getCommand().isEmpty() )
3375 xReportDefinition->setCommand(sCommand);
3376 xReportDefinition->setCommandType(nCommandType);
3379 xColumns = dbtools::getFieldsByCommandDescriptor(xConnection,nCommandType,sCommand,xHoldAlive);
3380 if ( xColumns.is() && xColumns->hasByName(sColumnName) )
3381 xField.set( xColumns->getByName( sColumnName ), uno::UNO_QUERY );
3384 if ( !xField.is() )
3386 #if OSL_DEBUG_LEVEL > 0
3389 uno::Reference< beans::XPropertySet > xRowSetProps( getRowSet(), UNO_QUERY_THROW );
3390 OUString sRowSetCommand;
3391 sal_Int32 nRowSetCommandType( -1 );
3392 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMAND ) >>= sRowSetCommand );
3393 OSL_VERIFY( xRowSetProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nRowSetCommandType );
3394 OSL_ENSURE( ( sRowSetCommand == sCommand ) && ( nCommandType == nRowSetCommandType ),
3395 "OReportController::addPairControls: this only works for a data source which equals our current settings!" );
3396 // if this asserts, then either our row set and our report definition are not in sync, or somebody
3397 // requested the creation of a control/pair for another data source than what our report
3398 // definition is bound to - which is not supported for the parameters case, since we
3399 // can retrieve parameters from the RowSet only.
3401 catch(const Exception&)
3403 DBG_UNHANDLED_EXCEPTION("reportdesign");
3405 #endif
3407 // no column name - perhaps a parameter name?
3408 uno::Reference< sdb::XParametersSupplier > xSuppParam( getRowSet(), uno::UNO_QUERY_THROW );
3409 uno::Reference< container::XIndexAccess > xParams( xSuppParam->getParameters(), uno::UNO_SET_THROW );
3410 sal_Int32 nParamCount( xParams->getCount() );
3411 for ( sal_Int32 i=0; i<nParamCount; ++i)
3413 uno::Reference< beans::XPropertySet > xParamCol( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
3414 OUString sParamName;
3415 OSL_VERIFY( xParamCol->getPropertyValue("Name") >>= sParamName );
3416 if ( sParamName == sColumnName )
3418 xField = xParamCol;
3419 break;
3424 if ( !xField.is() )
3425 continue;
3427 SdrObjKind nOBJID = OBJ_NONE;
3428 sal_Int32 nDataType = sdbc::DataType::BINARY;
3429 xField->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
3430 switch ( nDataType )
3432 case sdbc::DataType::BINARY:
3433 case sdbc::DataType::VARBINARY:
3434 case sdbc::DataType::LONGVARBINARY:
3435 nOBJID = OBJ_RD_IMAGECONTROL;
3436 break;
3437 default:
3438 nOBJID = OBJ_RD_FORMATTEDFIELD;
3439 break;
3442 if ( !nOBJID )
3443 continue;
3445 Reference< util::XNumberFormatsSupplier > xSupplier = getReportNumberFormatter()->getNumberFormatsSupplier();
3446 if ( !xSupplier.is() )
3447 continue;
3449 Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats());
3450 std::unique_ptr<SdrUnoObj, SdrObjectFreeOp> pControl[2];
3451 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(m_xReportDefinition,PROPERTY_RIGHTMARGIN);
3452 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_xReportDefinition,PROPERTY_PAPERSIZE).Width - nRightMargin;
3453 OSectionView* pSectionViews[2];
3454 pSectionViews[0] = &pSectionWindow[1]->getReportSection().getSectionView();
3455 pSectionViews[1] = &pSectionWindow[0]->getReportSection().getSectionView();
3457 // find this in svx
3458 FmFormView::createControlLabelPair(
3459 getDesignView()->GetOutDev(),
3460 nLeftMargin,
3462 xField,
3463 xNumberFormats,
3464 nOBJID,
3465 SdrInventor::ReportDesign,
3466 OBJ_RD_FIXEDTEXT,
3468 // tdf#118963 Need a SdrModel for SdrObject creation. Dereferencing
3469 // m_aReportModel seems pretty safe, it's done in other places, initialized
3470 // in impl_initialize and throws a RuntimeException if not existing.
3471 *m_aReportModel,
3473 pControl[0],
3474 pControl[1]);
3476 if ( pControl[0] && pControl[1] )
3478 SdrPageView* pPgViews[2];
3479 pPgViews[0] = pSectionViews[0]->GetSdrPageView();
3480 pPgViews[1] = pSectionViews[1]->GetSdrPageView();
3481 if ( pPgViews[0] && pPgViews[1] )
3483 OUString sDefaultName;
3484 size_t i = 0;
3485 OUnoObject* pObjs[2];
3486 for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i)
3488 pObjs[i] = dynamic_cast<OUnoObject*>(pControl[i].get());
3489 assert(pObjs[i]);
3490 uno::Reference<beans::XPropertySet> xUnoProp(pObjs[i]->GetUnoControlModel(),uno::UNO_QUERY_THROW);
3491 uno::Reference< report::XReportComponent> xShapeProp(pObjs[i]->getUnoShape(),uno::UNO_QUERY_THROW);
3492 xUnoProp->setPropertyValue(PROPERTY_NAME,xShapeProp->getPropertyValue(PROPERTY_NAME));
3494 uno::Reference<beans::XPropertySetInfo> xShapeInfo = xShapeProp->getPropertySetInfo();
3495 uno::Reference<beans::XPropertySetInfo> xInfo = xUnoProp->getPropertySetInfo();
3496 const OUString sProps[] = { OUString(PROPERTY_FONTDESCRIPTOR)
3497 ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
3498 ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
3499 ,OUString(PROPERTY_BORDER)
3500 ,OUString(PROPERTY_BACKGROUNDCOLOR)
3502 for(const auto & sProp : sProps)
3504 if ( xInfo->hasPropertyByName(sProp) && xShapeInfo->hasPropertyByName(sProp) )
3505 xUnoProp->setPropertyValue(sProp,xShapeProp->getPropertyValue(sProp));
3507 if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
3509 OUString sName;
3510 xUnoProp->getPropertyValue(PROPERTY_DATAFIELD) >>= sName;
3511 sDefaultName = sName;
3512 xUnoProp->setPropertyValue(PROPERTY_NAME,uno::makeAny(sDefaultName));
3514 ReportFormula aFormula( ReportFormula::Field, sName );
3515 xUnoProp->setPropertyValue( PROPERTY_DATAFIELD, uno::makeAny( aFormula.getCompleteFormula() ) );
3518 if ( xInfo->hasPropertyByName(PROPERTY_BORDER) && xShapeInfo->hasPropertyByName(PROPERTY_CONTROLBORDER) )
3519 xUnoProp->setPropertyValue(PROPERTY_BORDER,xShapeProp->getPropertyValue(PROPERTY_CONTROLBORDER));
3521 pObjs[i]->CreateMediator(true);
3523 const sal_Int32 nShapeWidth = xShapeProp->getWidth();
3524 const bool bChangedPos = (aPos.X + nShapeWidth) > nPaperWidth;
3525 if ( bChangedPos )
3526 aPos.X = nPaperWidth - nShapeWidth;
3527 xShapeProp->setPosition(aPos);
3528 if ( bChangedPos )
3529 aPos.Y += xShapeProp->getHeight();
3530 aPos.X += nShapeWidth;
3532 OUString sLabel;
3533 if ( xField->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
3534 xField->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
3536 if (pSectionViews[0] != pSectionViews[1] &&
3537 nOBJID == OBJ_RD_FORMATTEDFIELD) // we want this nice feature only at FORMATTEDFIELD
3539 uno::Reference< report::XReportComponent> xShapePropLabel(pObjs[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3540 uno::Reference< report::XReportComponent> xShapePropTextField(pObjs[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3541 if ( !sLabel.isEmpty() )
3542 xShapePropTextField->setName(sLabel);
3543 awt::Point aPosLabel = xShapePropLabel->getPosition();
3544 awt::Point aPosTextField = xShapePropTextField->getPosition();
3545 aPosTextField.X = aPosLabel.X;
3546 xShapePropTextField->setPosition(aPosTextField);
3547 if (bLabelAboveTextField)
3549 // move the label down near the splitter
3550 const uno::Reference<report::XSection> xLabelSection = pSectionWindow[1]->getReportSection().getSection();
3551 aPosLabel.Y = xLabelSection->getHeight() - xShapePropLabel->getHeight();
3553 else
3555 // move the label up to the splitter
3556 aPosLabel.Y = 0;
3558 xShapePropLabel->setPosition(aPosLabel);
3560 OUnoObject* pObj = dynamic_cast<OUnoObject*>(pControl[0].get());
3561 assert(pObj);
3562 uno::Reference< report::XFixedText> xShapeProp(pObj->getUnoShape(),uno::UNO_QUERY_THROW);
3563 xShapeProp->setName(xShapeProp->getName() + sDefaultName );
3565 for(i = 0; i < SAL_N_ELEMENTS(pControl); ++i) // insert controls
3567 correctOverlapping(pControl[i].get(), pSectionWindow[1-i]->getReportSection());
3570 if (!bLabelAboveTextField )
3572 if ( pSectionViews[0] == pSectionViews[1] )
3574 tools::Rectangle aLabel = getRectangleFromControl(pControl[0].get());
3575 tools::Rectangle aTextfield = getRectangleFromControl(pControl[1].get());
3577 // create a Union of the given Label and Textfield
3578 tools::Rectangle aLabelAndTextfield( aLabel );
3579 aLabelAndTextfield.Union(aTextfield);
3581 // check if there exists other fields and if yes, move down
3582 bool bOverlapping = true;
3583 bool bHasToMove = false;
3584 while ( bOverlapping )
3586 const SdrObject* pOverlappedObj = isOver(aLabelAndTextfield, *pSectionWindow[0]->getReportSection().getPage(), *pSectionViews[0], true, pControl, 2);
3587 bOverlapping = pOverlappedObj != nullptr;
3588 if ( bOverlapping )
3590 const tools::Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
3591 aLabelAndTextfield.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aLabelAndTextfield.Top());
3592 bHasToMove = true;
3596 if (bHasToMove)
3598 // There was a move down, we need to move the Label and the Textfield down
3599 aLabel.Move(0, aLabelAndTextfield.Top() - aLabel.Top());
3600 aTextfield.Move(0, aLabelAndTextfield.Top() - aTextfield.Top());
3602 uno::Reference< report::XReportComponent> xLabel(pControl[0]->getUnoShape(),uno::UNO_QUERY_THROW);
3603 xLabel->setPositionY(aLabel.Top());
3605 uno::Reference< report::XReportComponent> xTextfield(pControl[1]->getUnoShape(),uno::UNO_QUERY_THROW);
3606 xTextfield->setPositionY(aTextfield.Top());
3611 // not sure where the ownership of these passes too...
3612 pControl[0].release();
3613 pControl[1].release();
3617 catch(const Exception&)
3619 DBG_UNHANDLED_EXCEPTION("reportdesign");
3624 OSectionView* OReportController::getCurrentSectionView() const
3626 OSectionView* pSectionView = nullptr;
3627 OSectionWindow* pSectionWindow = getDesignView()->getMarkedSection();
3628 if ( pSectionWindow )
3629 pSectionView = &pSectionWindow->getReportSection().getSectionView();
3630 return pSectionView;
3633 void OReportController::changeZOrder(sal_Int32 _nId)
3635 OSectionView* pSectionView = getCurrentSectionView();
3636 if ( !pSectionView )
3637 return;
3639 switch(_nId)
3641 case SID_FRAME_TO_BOTTOM:
3642 pSectionView->PutMarkedToBtm();
3643 break;
3644 case SID_FRAME_TO_TOP:
3645 pSectionView->PutMarkedToTop();
3646 break;
3647 case SID_FRAME_DOWN:
3648 pSectionView->MovMarkedToBtm();
3649 break;
3650 case SID_FRAME_UP:
3651 pSectionView->MovMarkedToTop();
3652 break;
3654 case SID_OBJECT_HEAVEN:
3655 pSectionView->SetMarkedToLayer( RPT_LAYER_FRONT );
3656 break;
3657 case SID_OBJECT_HELL:
3658 pSectionView->SetMarkedToLayer( RPT_LAYER_BACK );
3659 break;
3663 void OReportController::listen(const bool _bAdd)
3665 const OUString aProps [] = { OUString(PROPERTY_REPORTHEADERON),OUString(PROPERTY_REPORTFOOTERON)
3666 ,OUString(PROPERTY_PAGEHEADERON),OUString(PROPERTY_PAGEFOOTERON)
3667 ,OUString(PROPERTY_COMMAND), OUString(PROPERTY_COMMANDTYPE),OUString(PROPERTY_CAPTION)
3670 void (SAL_CALL XPropertySet::*pPropertyListenerAction)( const OUString&, const uno::Reference< XPropertyChangeListener >& ) =
3671 _bAdd ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
3673 for (const auto & aProp : aProps)
3674 (m_xReportDefinition.get()->*pPropertyListenerAction)( aProp, static_cast< XPropertyChangeListener* >( this ) );
3676 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3677 uno::Reference< XPropertyChangeListener > xUndo = &rUndoEnv;
3678 const uno::Sequence< beans::Property> aSeq = m_xReportDefinition->getPropertySetInfo()->getProperties();
3679 const OUString* pPropsBegin = &aProps[0];
3680 const OUString* pPropsEnd = pPropsBegin + SAL_N_ELEMENTS(aProps) - 3;
3681 for(const beans::Property& rProp : aSeq)
3683 if ( ::std::find(pPropsBegin,pPropsEnd,rProp.Name) == pPropsEnd )
3684 (m_xReportDefinition.get()->*pPropertyListenerAction)( rProp.Name, xUndo );
3687 // Add Listeners to UndoEnvironment
3688 void (OXUndoEnvironment::*pElementUndoFunction)( const uno::Reference< uno::XInterface >& ) =
3689 _bAdd ? &OXUndoEnvironment::AddElement : &OXUndoEnvironment::RemoveElement;
3691 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getStyleFamilies() );
3692 (rUndoEnv.*pElementUndoFunction)( m_xReportDefinition->getFunctions() );
3694 // Add Listeners to ReportControllerObserver
3695 OXReportControllerObserver& rObserver = *m_pReportControllerObserver;
3697 if ( m_xReportDefinition->getPageHeaderOn() && _bAdd )
3699 getDesignView()->addSection(m_xReportDefinition->getPageHeader(),DBPAGEHEADER);
3700 rObserver.AddSection(m_xReportDefinition->getPageHeader());
3702 if ( m_xReportDefinition->getReportHeaderOn() && _bAdd )
3704 getDesignView()->addSection(m_xReportDefinition->getReportHeader(),DBREPORTHEADER);
3705 rObserver.AddSection(m_xReportDefinition->getReportHeader());
3708 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3709 const sal_Int32 nCount = xGroups->getCount();
3710 _bAdd ? xGroups->addContainerListener(&rUndoEnv) : xGroups->removeContainerListener(&rUndoEnv);
3711 _bAdd ? xGroups->addContainerListener(&rObserver) : xGroups->removeContainerListener(&rObserver);
3713 for (sal_Int32 i=0;i<nCount ; ++i)
3715 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i),uno::UNO_QUERY);
3716 (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_HEADERON), static_cast< XPropertyChangeListener* >( this ) );
3717 (xGroup.get()->*pPropertyListenerAction)( OUString(PROPERTY_FOOTERON), static_cast< XPropertyChangeListener* >( this ) );
3719 (rUndoEnv.*pElementUndoFunction)( xGroup );
3720 (rUndoEnv.*pElementUndoFunction)( xGroup->getFunctions() );
3721 if ( xGroup->getHeaderOn() && _bAdd )
3723 getDesignView()->addSection(xGroup->getHeader(),DBGROUPHEADER);
3724 rObserver.AddSection(xGroup->getHeader());
3728 if ( _bAdd )
3730 getDesignView()->addSection(m_xReportDefinition->getDetail(),DBDETAIL);
3731 rObserver.AddSection(m_xReportDefinition->getDetail());
3733 for (sal_Int32 i=nCount;i > 0 ; --i)
3735 uno::Reference< report::XGroup > xGroup(xGroups->getByIndex(i-1),uno::UNO_QUERY);
3736 if ( xGroup->getFooterOn() )
3738 getDesignView()->addSection(xGroup->getFooter(),DBGROUPFOOTER);
3739 rObserver.AddSection(xGroup->getFooter());
3742 if ( m_xReportDefinition->getReportFooterOn() )
3744 getDesignView()->addSection(m_xReportDefinition->getReportFooter(),DBREPORTFOOTER);
3745 rObserver.AddSection(m_xReportDefinition->getReportFooter());
3747 if ( m_xReportDefinition->getPageFooterOn())
3749 getDesignView()->addSection(m_xReportDefinition->getPageFooter(),DBPAGEFOOTER);
3750 rObserver.AddSection(m_xReportDefinition->getPageFooter());
3753 xGroups->addContainerListener(static_cast<XContainerListener*>(this));
3754 m_xReportDefinition->addModifyListener(static_cast<XModifyListener*>(this));
3756 else /* ! _bAdd */
3758 rObserver.RemoveSection(m_xReportDefinition->getDetail());
3759 xGroups->removeContainerListener(static_cast<XContainerListener*>(this));
3760 m_xReportDefinition->removeModifyListener(static_cast<XModifyListener*>(this));
3761 m_aReportModel->detachController();
3765 void OReportController::switchReportSection(const sal_Int16 _nId)
3767 OSL_ENSURE(_nId == SID_REPORTHEADER_WITHOUT_UNDO || _nId == SID_REPORTFOOTER_WITHOUT_UNDO || _nId == SID_REPORTHEADERFOOTER ,"Illegal id given!");
3769 if ( !m_xReportDefinition.is() )
3770 return;
3772 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3773 const bool bSwitchOn = !m_xReportDefinition->getReportHeaderOn();
3775 std::unique_ptr< UndoContext > pUndoContext;
3776 if ( SID_REPORTHEADERFOOTER == _nId )
3778 const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3779 pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3781 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel,SID_REPORTHEADER_WITHOUT_UNDO
3782 ,::std::mem_fn(&OReportHelper::getReportHeader)
3783 ,m_xReportDefinition
3784 ,bSwitchOn ? Inserted : Removed
3787 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel,SID_REPORTFOOTER_WITHOUT_UNDO
3788 ,::std::mem_fn(&OReportHelper::getReportFooter)
3789 ,m_xReportDefinition
3790 ,bSwitchOn ? Inserted : Removed
3794 switch( _nId )
3796 case SID_REPORTHEADER_WITHOUT_UNDO:
3797 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3798 break;
3799 case SID_REPORTFOOTER_WITHOUT_UNDO:
3800 m_xReportDefinition->setReportFooterOn( !m_xReportDefinition->getReportFooterOn() );
3801 break;
3802 case SID_REPORTHEADERFOOTER:
3803 m_xReportDefinition->setReportHeaderOn( bSwitchOn );
3804 m_xReportDefinition->setReportFooterOn( bSwitchOn );
3805 break;
3808 if ( SID_REPORTHEADERFOOTER == _nId )
3809 pUndoContext.reset();
3810 getView()->Resize();
3813 void OReportController::switchPageSection(const sal_Int16 _nId)
3815 OSL_ENSURE(_nId == SID_PAGEHEADERFOOTER || _nId == SID_PAGEHEADER_WITHOUT_UNDO || _nId == SID_PAGEFOOTER_WITHOUT_UNDO ,"Illegal id given!");
3816 if ( !m_xReportDefinition.is() )
3817 return;
3819 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3820 const bool bSwitchOn = !m_xReportDefinition->getPageHeaderOn();
3822 std::unique_ptr< UndoContext > pUndoContext;
3823 if ( SID_PAGEHEADERFOOTER == _nId )
3825 const OUString sUndoAction(RptResId(bSwitchOn ? RID_STR_UNDO_ADD_REPORTHEADERFOOTER : RID_STR_UNDO_REMOVE_REPORTHEADERFOOTER));
3826 pUndoContext.reset( new UndoContext( getUndoManager(), sUndoAction ) );
3828 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel
3829 ,SID_PAGEHEADER_WITHOUT_UNDO
3830 ,::std::mem_fn(&OReportHelper::getPageHeader)
3831 ,m_xReportDefinition
3832 ,bSwitchOn ? Inserted : Removed
3835 addUndoAction(std::make_unique<OReportSectionUndo>(*m_aReportModel
3836 ,SID_PAGEFOOTER_WITHOUT_UNDO
3837 ,::std::mem_fn(&OReportHelper::getPageFooter)
3838 ,m_xReportDefinition
3839 ,bSwitchOn ? Inserted : Removed
3842 switch( _nId )
3844 case SID_PAGEHEADER_WITHOUT_UNDO:
3845 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3846 break;
3847 case SID_PAGEFOOTER_WITHOUT_UNDO:
3848 m_xReportDefinition->setPageFooterOn( !m_xReportDefinition->getPageFooterOn() );
3849 break;
3850 case SID_PAGEHEADERFOOTER:
3851 m_xReportDefinition->setPageHeaderOn( bSwitchOn );
3852 m_xReportDefinition->setPageFooterOn( bSwitchOn );
3853 break;
3855 if ( SID_PAGEHEADERFOOTER == _nId )
3856 pUndoContext.reset();
3857 getView()->Resize();
3860 void OReportController::modifyGroup(const bool _bAppend, const Sequence< PropertyValue >& _aArgs)
3862 if ( !m_xReportDefinition.is() )
3863 return;
3867 const SequenceAsHashMap aMap( _aArgs );
3868 uno::Reference< report::XGroup > xGroup = aMap.getUnpackedValueOrDefault( PROPERTY_GROUP, uno::Reference< report::XGroup >() );
3869 if ( !xGroup.is() )
3870 return;
3872 OXUndoEnvironment& rUndoEnv = m_aReportModel->GetUndoEnv();
3873 uno::Reference< report::XGroups > xGroups = m_xReportDefinition->getGroups();
3874 if ( _bAppend )
3876 const sal_Int32 nPos = aMap.getUnpackedValueOrDefault( PROPERTY_POSITIONY, xGroups->getCount() );
3877 xGroups->insertByIndex( nPos, uno::makeAny( xGroup ) );
3878 rUndoEnv.AddElement( xGroup->getFunctions() );
3881 addUndoAction( std::make_unique<OGroupUndo>(
3882 *m_aReportModel,
3883 _bAppend ? RID_STR_UNDO_APPEND_GROUP : RID_STR_UNDO_REMOVE_GROUP,
3884 _bAppend ? Inserted : Removed,
3885 xGroup,
3886 m_xReportDefinition
3887 ) );
3889 if ( !_bAppend )
3891 rUndoEnv.RemoveElement( xGroup->getFunctions() );
3892 const sal_Int32 nPos = getGroupPosition( xGroup );
3893 const OXUndoEnvironment::OUndoEnvLock aLock( m_aReportModel->GetUndoEnv() );
3894 xGroups->removeByIndex( nPos );
3897 catch(const Exception&)
3899 DBG_UNHANDLED_EXCEPTION("reportdesign");
3904 void OReportController::createGroupSection(const bool _bUndo,const bool _bHeader, const Sequence< PropertyValue >& _aArgs)
3906 if ( !m_xReportDefinition.is() )
3907 return;
3909 const SequenceAsHashMap aMap(_aArgs);
3910 const bool bSwitchOn = aMap.getUnpackedValueOrDefault(_bHeader ? OUString(PROPERTY_HEADERON) : OUString(PROPERTY_FOOTERON), false);
3911 uno::Reference< report::XGroup> xGroup = aMap.getUnpackedValueOrDefault(PROPERTY_GROUP,uno::Reference< report::XGroup>());
3912 if ( !xGroup.is() )
3913 return;
3915 const OXUndoEnvironment::OUndoEnvLock aLock(m_aReportModel->GetUndoEnv());
3916 if ( _bUndo )
3917 addUndoAction(std::make_unique<OGroupSectionUndo>(*m_aReportModel
3918 ,_bHeader ? SID_GROUPHEADER_WITHOUT_UNDO : SID_GROUPFOOTER_WITHOUT_UNDO
3919 ,_bHeader ? ::std::mem_fn(&OGroupHelper::getHeader) : ::std::mem_fn(&OGroupHelper::getFooter)
3920 ,xGroup
3921 ,bSwitchOn ? Inserted : Removed
3922 , ( _bHeader ?
3923 (bSwitchOn ? RID_STR_UNDO_ADD_GROUP_HEADER : RID_STR_UNDO_REMOVE_GROUP_HEADER)
3924 :(bSwitchOn ? RID_STR_UNDO_ADD_GROUP_FOOTER : RID_STR_UNDO_REMOVE_GROUP_FOOTER)
3928 if ( _bHeader )
3929 xGroup->setHeaderOn( bSwitchOn );
3930 else
3931 xGroup->setFooterOn( bSwitchOn );
3934 void OReportController::collapseSection(const bool _bCollapse)
3936 OSectionWindow *pSection = getDesignView()->getMarkedSection();
3937 if ( pSection )
3939 pSection->setCollapsed(_bCollapse);
3943 void OReportController::markSection(const bool _bNext)
3945 OSectionWindow *pSection = getDesignView()->getMarkedSection();
3946 if ( pSection )
3948 OSectionWindow *pPrevSection = getDesignView()->getMarkedSection(_bNext ? POST : PREVIOUS);
3949 if ( pPrevSection != pSection && pPrevSection )
3950 select(uno::makeAny(pPrevSection->getReportSection().getSection()));
3951 else
3952 select(uno::makeAny(m_xReportDefinition));
3954 else
3956 getDesignView()->markSection(_bNext ? 0 : getDesignView()->getSectionCount() - 1);
3957 pSection = getDesignView()->getMarkedSection();
3958 if ( pSection )
3959 select(uno::makeAny(pSection->getReportSection().getSection()));
3963 void OReportController::createDefaultControl(const uno::Sequence< beans::PropertyValue>& _aArgs)
3965 uno::Reference< report::XSection > xSection = getDesignView()->getCurrentSection();
3966 if ( !xSection.is() )
3967 xSection = m_xReportDefinition->getDetail();
3969 if ( !xSection.is() )
3970 return;
3972 const beans::PropertyValue* pIter = _aArgs.getConstArray();
3973 const beans::PropertyValue* pEnd = pIter + _aArgs.getLength();
3974 const beans::PropertyValue* pKeyModifier = ::std::find_if(pIter, pEnd,
3975 [] (const beans::PropertyValue& x) -> bool {
3976 return x.Name == "KeyModifier";
3978 sal_Int16 nKeyModifier = 0;
3979 if ( pKeyModifier == pEnd || ((pKeyModifier->Value >>= nKeyModifier) && nKeyModifier == KEY_MOD1) )
3981 Sequence< PropertyValue > aCreateArgs;
3982 getDesignView()->unmarkAllObjects();
3983 createControl(aCreateArgs,xSection,OUString(),getDesignView()->GetInsertObj());
3988 void OReportController::checkChartEnabled()
3990 if ( m_bChartEnabledAsked )
3991 return;
3993 m_bChartEnabledAsked = true;
3997 ::utl::OConfigurationTreeRoot aConfiguration(
3998 ::utl::OConfigurationTreeRoot::createWithComponentContext( m_xContext, "/org.openoffice.Office.ReportDesign" ) );
4000 bool bChartEnabled = false;
4001 static const OUStringLiteral sPropertyName( u"UserData/Chart" );
4002 if ( aConfiguration.hasByHierarchicalName(sPropertyName) )
4003 aConfiguration.getNodeValue( sPropertyName ) >>= bChartEnabled;
4004 m_bChartEnabled = bChartEnabled;
4006 catch(const Exception&)
4012 // css.frame.XTitle
4013 OUString SAL_CALL OReportController::getTitle()
4015 SolarMutexGuard aSolarGuard;
4016 ::osl::MutexGuard aGuard( getMutex() );
4018 uno::Reference< frame::XTitle> xTitle(m_xReportDefinition,uno::UNO_QUERY_THROW);
4020 return xTitle->getTitle ();
4023 void OReportController::getPropertyDefaultByHandle( sal_Int32 /*_nHandle*/, Any& _rDefault ) const
4025 _rDefault <<= sal_Int16(100);
4028 // comphelper::OPropertyArrayUsageHelper
4029 ::cppu::IPropertyArrayHelper* OReportController::createArrayHelper( ) const
4031 Sequence< Property > aProps;
4032 describeProperties(aProps);
4033 return new ::cppu::OPropertyArrayHelper(aProps);
4037 // cppu::OPropertySetHelper
4038 ::cppu::IPropertyArrayHelper& SAL_CALL OReportController::getInfoHelper()
4040 return *::comphelper::OPropertyArrayUsageHelper<OReportController_BASE>::getArrayHelper();
4043 void SAL_CALL OReportController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle,const Any& _aValue)
4045 if ( _nHandle == PROPERTY_ID_ZOOMVALUE )
4047 _aValue >>= m_nZoomValue;
4048 impl_zoom_nothrow();
4051 void SAL_CALL OReportController::setMode( const OUString& aMode )
4053 ::osl::MutexGuard aGuard( getMutex() );
4054 m_sMode = aMode;
4056 OUString SAL_CALL OReportController::getMode( )
4058 ::osl::MutexGuard aGuard( getMutex() );
4059 return m_sMode;
4061 css::uno::Sequence< OUString > SAL_CALL OReportController::getSupportedModes( )
4063 return uno::Sequence< OUString> { OUString("remote"), OUString("normal") };
4065 sal_Bool SAL_CALL OReportController::supportsMode( const OUString& aMode )
4067 uno::Sequence< OUString> aModes = getSupportedModes();
4068 return comphelper::findValue(aModes, aMode) != -1;
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 )
4080 return;
4082 ::std::vector< uno::Reference< uno::XInterface > > aSelection;
4083 getDesignView()->fillControlModelSelection(aSelection);
4084 _rState.bEnabled = !aSelection.empty();
4085 if ( !_rState.bEnabled )
4086 return;
4088 uno::Any aTemp;
4089 ::std::vector< uno::Reference< uno::XInterface > >::const_iterator aIter = aSelection.begin();
4090 for(; aIter != aSelection.end() && _rState.bEnabled ;++aIter)
4092 uno::Reference< beans::XPropertySet> xProp(*aIter,uno::UNO_QUERY);
4095 uno::Any aTemp2 = xProp->getPropertyValue(_sProperty);
4096 if ( aIter == aSelection.begin() )
4098 aTemp = aTemp2;
4100 else if ( aTemp != aTemp2 )
4101 break;
4103 catch(const beans::UnknownPropertyException&)
4105 _rState.bEnabled = false;
4108 if ( aIter == aSelection.end() )
4109 _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(TranslateId 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&)
4175 TOOLS_WARN_EXCEPTION("reportdesign", "");
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 rtl::Reference<SfxItemPool> pPool( new SfxItemPool("ZoomProperties", SID_ATTR_ZOOM,SID_ATTR_ZOOM, aItemInfos, &pDefaults) );
4214 pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
4215 pPool->FreezeIdRanges(); // the same
4218 SfxItemSetFixed<SID_ATTR_ZOOM,SID_ATTR_ZOOM> aDescriptor(*pPool);
4219 // fill it
4220 SvxZoomItem aZoomItem( m_eZoomType, m_nZoomValue, SID_ATTR_ZOOM );
4221 aZoomItem.SetValueSet(SvxZoomEnableFlags::N100|SvxZoomEnableFlags::WHOLEPAGE|SvxZoomEnableFlags::PAGEWIDTH);
4222 aDescriptor.Put(aZoomItem);
4224 ScopedVclPtr<AbstractSvxZoomDialog> pDlg(pFact->CreateSvxZoomDialog(nullptr, aDescriptor));
4225 pDlg->SetLimits( 20, 400 );
4226 bool bCancel = ( RET_CANCEL == pDlg->Execute() );
4228 if ( !bCancel )
4230 const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->Get( SID_ATTR_ZOOM );
4231 m_eZoomType = rZoomItem.GetType();
4232 m_nZoomValue = rZoomItem.GetValue();
4233 if ( m_eZoomType != SvxZoomType::PERCENT )
4234 m_nZoomValue = getDesignView()->getZoomFactor( m_eZoomType );
4236 impl_zoom_nothrow();
4239 catch(const uno::Exception&)
4241 DBG_UNHANDLED_EXCEPTION("reportdesign");
4243 pPool.clear();
4245 for (SfxPoolItem* pDefault : pDefaults)
4246 delete pDefault;
4250 // XVisualObject
4251 void SAL_CALL OReportController::setVisualAreaSize( ::sal_Int64 _nAspect, const awt::Size& _aSize )
4253 ::osl::MutexGuard aGuard( getMutex() );
4254 bool bChanged =
4255 (m_aVisualAreaSize.Width != _aSize.Width ||
4256 m_aVisualAreaSize.Height != _aSize.Height);
4257 m_aVisualAreaSize = _aSize;
4258 if( bChanged )
4259 setModified( true );
4260 m_nAspect = _nAspect;
4263 awt::Size SAL_CALL OReportController::getVisualAreaSize( ::sal_Int64 /*nAspect*/ )
4265 ::osl::MutexGuard aGuard( getMutex() );
4266 return m_aVisualAreaSize;
4269 embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepresentation( ::sal_Int64 _nAspect )
4271 SolarMutexGuard aSolarGuard;
4272 ::osl::MutexGuard aGuard( getMutex() );
4273 embed::VisualRepresentation aResult;
4274 if ( !m_bInGeneratePreview )
4276 m_bInGeneratePreview = true;
4279 if ( !m_xReportEngine.is() )
4280 m_xReportEngine.set( report::ReportEngine::create(m_xContext) );
4281 const sal_Int32 nOldMaxRows = m_xReportEngine->getMaxRows();
4282 m_xReportEngine->setMaxRows(MAX_ROWS_FOR_PREVIEW);
4283 m_xReportEngine->setReportDefinition(m_xReportDefinition);
4284 m_xReportEngine->setActiveConnection(getConnection());
4287 Reference<embed::XVisualObject> xTransfer(m_xReportEngine->createDocumentModel(),UNO_QUERY);
4288 if ( xTransfer.is() )
4290 xTransfer->setVisualAreaSize(m_nAspect,m_aVisualAreaSize);
4291 aResult = xTransfer->getPreferredVisualRepresentation( _nAspect );
4294 catch(const uno::Exception&)
4297 m_xReportEngine->setMaxRows(nOldMaxRows);
4299 catch(const uno::Exception&)
4302 m_bInGeneratePreview = false;
4304 return aResult;
4307 ::sal_Int32 SAL_CALL OReportController::getMapUnit( ::sal_Int64 /*nAspect*/ )
4309 return embed::EmbedMapUnits::ONE_100TH_MM;
4312 uno::Reference< container::XNameAccess > const & OReportController::getColumns() const
4314 if ( !m_xColumns.is() && m_xReportDefinition.is() && !m_xReportDefinition->getCommand().isEmpty() )
4316 m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive);
4318 return m_xColumns;
4321 OUString OReportController::getColumnLabel_throw(const OUString& i_sColumnName) const
4323 OUString sLabel;
4324 uno::Reference< container::XNameAccess > xColumns = getColumns();
4325 if ( xColumns.is() && xColumns->hasByName(i_sColumnName) )
4327 uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW);
4328 if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
4329 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
4331 return sLabel;
4335 SfxUndoManager& OReportController::getUndoManager() const
4337 DBG_TESTSOLARMUTEX();
4338 // this is expected to be called during UI actions, so the SM is assumed to be locked
4340 std::shared_ptr< OReportModel > pReportModel( getSdrModel() );
4341 ENSURE_OR_THROW( !!pReportModel, "no access to our model" );
4343 SfxUndoManager* pUndoManager( pReportModel->GetSdrUndoManager() );
4344 ENSURE_OR_THROW( pUndoManager != nullptr, "no access to our model's UndoManager" );
4346 return *pUndoManager;
4350 void OReportController::clearUndoManager() const
4352 getUndoManager().Clear();
4356 void OReportController::addUndoAction( std::unique_ptr<SfxUndoAction> i_pAction )
4358 getUndoManager().AddUndoAction( std::move(i_pAction) );
4360 InvalidateFeature( SID_UNDO );
4361 InvalidateFeature( SID_REDO );
4364 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
4365 reportdesign_OReportController_get_implementation(
4366 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
4368 return cppu::acquire(new OReportController(context));
4372 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */