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