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