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