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 :
21 : #include <toolkit/helper/convert.hxx>
22 : #include <toolkit/helper/vclunohelper.hxx>
23 : #include "SectionView.hxx"
24 : #include "UITools.hxx"
25 : #include "Formula.hxx"
26 : #include "FunctionHelper.hxx"
27 : #include "reportformula.hxx"
28 :
29 : #include <tools/diagnose_ex.h>
30 :
31 : #include <vcl/svapp.hxx>
32 : #include <vcl/window.hxx>
33 : #include <vcl/settings.hxx>
34 :
35 : #include <com/sun/star/lang/NullPointerException.hpp>
36 : #include <com/sun/star/beans/NamedValue.hpp>
37 : #include <com/sun/star/beans/PropertyAttribute.hpp>
38 : #include <svx/svdpool.hxx>
39 :
40 : #include <editeng/charscaleitem.hxx>
41 : #include <svx/algitem.hxx>
42 : #include <svx/svdpagv.hxx>
43 : #include <svx/xtable.hxx>
44 : #include <editeng/brushitem.hxx>
45 : #include <editeng/fontitem.hxx>
46 : #include <editeng/emphasismarkitem.hxx>
47 : #include <editeng/postitem.hxx>
48 : #include <editeng/udlnitem.hxx>
49 : #include <editeng/crossedoutitem.hxx>
50 : #include <editeng/contouritem.hxx>
51 : #include <editeng/langitem.hxx>
52 : #include <editeng/wghtitem.hxx>
53 : #include <editeng/fhgtitem.hxx>
54 : #include <editeng/shdditem.hxx>
55 : #include <editeng/escapementitem.hxx>
56 : #include <editeng/prszitem.hxx>
57 : #include <editeng/wrlmitem.hxx>
58 : #include <editeng/cmapitem.hxx>
59 : #include <editeng/kernitem.hxx>
60 : #include <editeng/blinkitem.hxx>
61 : #include <editeng/flstitem.hxx>
62 : #include <editeng/autokernitem.hxx>
63 : #include <editeng/colritem.hxx>
64 : #include <editeng/justifyitem.hxx>
65 : #include <svx/drawitem.hxx>
66 : #include <editeng/twolinesitem.hxx>
67 : #include <editeng/charreliefitem.hxx>
68 : #include <editeng/charrotateitem.hxx>
69 : #include <editeng/charhiddenitem.hxx>
70 : #include <svx/xgrscit.hxx>
71 : #include <svx/svditer.hxx>
72 : #include <svx/xtable.hxx>
73 : #include <svx/dialogs.hrc>
74 : #include <svx/svdview.hxx>
75 : #include <svx/svdpage.hxx>
76 : #include <svx/svxdlg.hxx>
77 : #include <svx/unoprov.hxx>
78 :
79 : #include <unotools/pathoptions.hxx>
80 : #include <svtools/ctrltool.hxx>
81 : #include <svl/itempool.hxx>
82 : #include <svl/itemset.hxx>
83 :
84 : #include <comphelper/propmultiplex.hxx>
85 : #include <comphelper/namedvaluecollection.hxx>
86 :
87 : #include <connectivity/dbexception.hxx>
88 : #include <connectivity/dbconversion.hxx>
89 : #include <connectivity/dbtools.hxx>
90 :
91 : #include <com/sun/star/report/XGroups.hpp>
92 : #include <com/sun/star/awt/TextAlign.hpp>
93 : #include <com/sun/star/style/VerticalAlignment.hpp>
94 : #include <com/sun/star/report/XShape.hpp>
95 : #include <com/sun/star/report/Function.hpp>
96 : #include <com/sun/star/sdb/XParametersSupplier.hpp>
97 : #include <com/sun/star/sdb/SQLContext.hpp>
98 : #include <i18nlangtag/languagetag.hxx>
99 : #include "dlgpage.hxx"
100 : #include <vcl/msgbox.hxx>
101 : #include "rptui_slotid.hrc"
102 : #include "uistrings.hrc"
103 : #include "RptObject.hxx"
104 : #include "ModuleHelper.hxx"
105 : #include "RptDef.hxx"
106 : #include "RptResId.hrc"
107 : #include "ReportDefinition.hxx"
108 : #include "RptModel.hxx"
109 :
110 : #define ITEMID_FONT 10
111 : #define ITEMID_FONTHEIGHT 11
112 : #define ITEMID_LANGUAGE 12
113 :
114 : #define ITEMID_POSTURE 13
115 : #define ITEMID_WEIGHT 14
116 : #define ITEMID_SHADOWED 15
117 : #define ITEMID_WORDLINEMODE 16
118 : #define ITEMID_CONTOUR 17
119 : #define ITEMID_CROSSEDOUT 18
120 : #define ITEMID_UNDERLINE 19
121 :
122 : #define ITEMID_COLOR 20
123 : #define ITEMID_KERNING 21
124 : #define ITEMID_CASEMAP 22
125 :
126 : #define ITEMID_ESCAPEMENT 23
127 : #define ITEMID_FONTLIST 24
128 : #define ITEMID_AUTOKERN 25
129 : #define ITEMID_COLOR_TABLE 26
130 : #define ITEMID_BLINK 27
131 : #define ITEMID_EMPHASISMARK 28
132 : #define ITEMID_TWOLINES 29
133 : #define ITEMID_CHARROTATE 30
134 : #define ITEMID_CHARSCALE_W 31
135 : #define ITEMID_CHARRELIEF 32
136 : #define ITEMID_CHARHIDDEN 33
137 : #define ITEMID_BRUSH 34
138 : #define ITEMID_HORJUSTIFY 35
139 : #define ITEMID_VERJUSTIFY 36
140 : #define ITEMID_FONT_ASIAN 37
141 : #define ITEMID_FONTHEIGHT_ASIAN 38
142 : #define ITEMID_LANGUAGE_ASIAN 39
143 : #define ITEMID_POSTURE_ASIAN 40
144 : #define ITEMID_WEIGHT_ASIAN 41
145 : #define ITEMID_FONT_COMPLEX 42
146 : #define ITEMID_FONTHEIGHT_COMPLEX 43
147 : #define ITEMID_LANGUAGE_COMPLEX 44
148 : #define ITEMID_POSTURE_COMPLEX 45
149 : #define ITEMID_WEIGHT_COMPLEX 46
150 :
151 : #define WESTERN 0
152 : #define ASIAN 1
153 : #define COMPLEX 2
154 :
155 : namespace rptui
156 : {
157 : using namespace ::com::sun::star;
158 : using namespace formula;
159 :
160 0 : void adjustSectionName(const uno::Reference< report::XGroup >& _xGroup,sal_Int32 _nPos)
161 : {
162 : OSL_ENSURE(_xGroup.is(),"Group is NULL -> GPF");
163 0 : if ( _xGroup->getHeaderOn() && _xGroup->getHeader()->getName().isEmpty() )
164 : {
165 0 : OUString sName = ModuleRes(RID_STR_GROUPHEADER);
166 0 : sName += OUString::number(_nPos);
167 0 : _xGroup->getHeader()->setName(sName);
168 : }
169 :
170 0 : if ( _xGroup->getFooterOn() && _xGroup->getFooter()->getName().isEmpty() )
171 : {
172 0 : OUString sName = ModuleRes(RID_STR_GROUPFOOTER);
173 0 : sName += OUString::number(_nPos);
174 0 : _xGroup->getFooter()->setName(sName);
175 : }
176 0 : }
177 :
178 0 : ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener(const uno::Reference< report::XReportDefinition >& _xReportDefinition,::comphelper::OPropertyChangeListener* _pListener)
179 : {
180 0 : ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> pRet = NULL;
181 0 : if ( _xReportDefinition.is() )
182 : {
183 0 : uno::Reference<beans::XPropertySet> xPageStyle(getUsedStyle(_xReportDefinition),uno::UNO_QUERY);
184 0 : if ( xPageStyle.is() )
185 : {
186 0 : pRet = new comphelper::OPropertyChangeMultiplexer(_pListener,xPageStyle);
187 0 : pRet->addProperty(PROPERTY_LEFTMARGIN);
188 0 : pRet->addProperty(PROPERTY_RIGHTMARGIN);
189 0 : pRet->addProperty(PROPERTY_PAPERSIZE);
190 0 : pRet->addProperty(PROPERTY_BACKCOLOR);
191 0 : }
192 : }
193 0 : return pRet;
194 : }
195 :
196 :
197 : namespace
198 : {
199 :
200 0 : Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat, awt::FontDescriptor& _out_rControlFont ,sal_uInt16 _nWichFont)
201 : {
202 0 : if ( !_rxReportControlFormat.is() )
203 0 : throw uno::RuntimeException();
204 :
205 0 : switch(_nWichFont)
206 : {
207 : case WESTERN:
208 0 : _out_rControlFont = _rxReportControlFormat->getFontDescriptor();
209 0 : break;
210 : case ASIAN:
211 0 : _out_rControlFont = _rxReportControlFormat->getFontDescriptorAsian();
212 0 : break;
213 : case COMPLEX:
214 0 : _out_rControlFont = _rxReportControlFormat->getFontDescriptorComplex();
215 0 : break;
216 :
217 : }
218 :
219 0 : Font aDefaultFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
220 0 : return VCLUnoHelper::CreateFont( _out_rControlFont, aDefaultFont );
221 : }
222 :
223 :
224 0 : Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,sal_uInt16 _nWhich )
225 : {
226 0 : awt::FontDescriptor aAwtFont;
227 0 : return lcl_getReportControlFont( _rxReportControlFormat, aAwtFont, _nWhich );
228 : }
229 :
230 0 : const Font lcl_setFont(const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
231 : SfxItemSet& _rItemSet,sal_uInt16 _nWhich,sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nLanguage,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
232 : {
233 : // fill it
234 0 : awt::FontDescriptor aControlFont;
235 0 : const Font aFont( lcl_getReportControlFont( _rxReportControlFormat, aControlFont,_nWhich ) );
236 :
237 0 : SvxFontItem aFontItem(_nFont);
238 0 : aFontItem.PutValue( uno::makeAny( aControlFont ) );
239 0 : _rItemSet.Put(aFontItem);
240 :
241 0 : _rItemSet.Put(SvxFontHeightItem(OutputDevice::LogicToLogic(Size(0, (sal_Int32)aFont.GetHeight()), MAP_POINT, MAP_TWIP).Height(),100,_nFontHeight));
242 0 : lang::Locale aLocale;
243 0 : switch(_nWhich)
244 : {
245 : default:
246 0 : aLocale = _rxReportControlFormat->getCharLocale();
247 0 : break;
248 : case ASIAN:
249 0 : aLocale = _rxReportControlFormat->getCharLocaleAsian();
250 0 : break;
251 : case COMPLEX:
252 0 : aLocale = _rxReportControlFormat->getCharLocaleComplex();
253 0 : break;
254 : }
255 :
256 0 : _rItemSet.Put(SvxLanguageItem(LanguageTag(aLocale).makeFallback().getLanguageType(),_nLanguage));
257 :
258 0 : _rItemSet.Put(SvxPostureItem(aFont.GetItalic(),_nPosture));
259 0 : _rItemSet.Put(SvxWeightItem(aFont.GetWeight(),_nWeight));
260 0 : return aFont;
261 : }
262 :
263 0 : void lcl_fillShapeToItems( const uno::Reference<report::XShape >& _xShape,SfxItemSet& _rItemSet )
264 : {
265 0 : uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
266 0 : SvxUnoPropertyMapProvider aMap;
267 0 : const SfxItemPropertyMap* pPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
268 0 : PropertyEntryVector_t aPropVector = pPropertyMap->getPropertyEntries();
269 0 : PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
270 0 : while( aIt != aPropVector.end() )
271 : {
272 0 : if ( xInfo->hasPropertyByName(aIt->sName) )
273 : {
274 0 : const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
275 0 : if ( pItem )
276 : {
277 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
278 0 : ::std::auto_ptr<SfxPoolItem> pClone(pItem->Clone());
279 : SAL_WNODEPRECATED_DECLARATIONS_POP
280 0 : pClone->PutValue(_xShape->getPropertyValue(aIt->sName), aIt->nMemberId);
281 0 : _rItemSet.Put(*pClone, aIt->nWID);
282 : }
283 : }
284 0 : ++aIt;
285 0 : }
286 0 : }
287 :
288 0 : void lcl_fillItemsToShape( const uno::Reference<report::XShape >& _xShape,const SfxItemSet& _rItemSet )
289 : {
290 0 : const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
291 0 : SvxUnoPropertyMapProvider aMap;
292 0 : const SfxItemPropertyMap* pPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
293 0 : PropertyEntryVector_t aPropVector = pPropertyMap->getPropertyEntries();
294 0 : PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
295 0 : while( aIt != aPropVector.end() )
296 : {
297 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState(aIt->nWID) && xInfo->hasPropertyByName(aIt->sName) )
298 : {
299 0 : const beans::Property aProp = xInfo->getPropertyByName( aIt->sName );
300 0 : if ( ( aIt->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
301 : {
302 0 : const SfxPoolItem* pItem = _rItemSet.GetItem(aIt->nWID);
303 0 : if ( pItem )
304 : {
305 0 : uno::Any aValue;
306 0 : pItem->QueryValue(aValue,aIt->nMemberId);
307 : try
308 : {
309 0 : _xShape->setPropertyValue(aIt->sName, aValue);
310 : }
311 0 : catch(uno::Exception&)
312 : { // shapes have a bug so we ignore this one.
313 0 : }
314 : }
315 0 : }
316 : }
317 0 : ++aIt;
318 0 : }
319 0 : }
320 :
321 0 : void lcl_CharPropertiesToItems( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
322 : SfxItemSet& _rItemSet )
323 : {
324 0 : if ( !_rxReportControlFormat.is() )
325 0 : throw lang::NullPointerException();
326 :
327 0 : uno::Reference< beans::XPropertySet > xSet(_rxReportControlFormat,uno::UNO_QUERY_THROW);
328 :
329 : // fill it
330 0 : const Font aFont( lcl_setFont(_rxReportControlFormat, _rItemSet,WESTERN,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_LANGUAGE,ITEMID_POSTURE,ITEMID_WEIGHT ) );
331 :
332 0 : _rItemSet.Put(SvxShadowedItem(_rxReportControlFormat->getCharShadowed(),ITEMID_SHADOWED));
333 0 : _rItemSet.Put(SvxWordLineModeItem(aFont.IsWordLineMode(),ITEMID_WORDLINEMODE));
334 0 : _rItemSet.Put(SvxContourItem(_rxReportControlFormat->getCharContoured(),ITEMID_CONTOUR));
335 0 : _rItemSet.Put(SvxAutoKernItem(_rxReportControlFormat->getCharAutoKerning(),ITEMID_AUTOKERN));
336 0 : _rItemSet.Put(SvxCrossedOutItem(aFont.GetStrikeout(),ITEMID_CROSSEDOUT));
337 0 : _rItemSet.Put(SvxCaseMapItem(static_cast<SvxCaseMap>(_rxReportControlFormat->getCharCaseMap()),ITEMID_CASEMAP));
338 :
339 0 : _rItemSet.Put(SvxEscapementItem(_rxReportControlFormat->getCharEscapement(),_rxReportControlFormat->getCharEscapementHeight(),ITEMID_ESCAPEMENT));
340 0 : _rItemSet.Put(SvxBlinkItem(_rxReportControlFormat->getCharFlash(),ITEMID_BLINK));
341 0 : _rItemSet.Put(SvxCharHiddenItem(_rxReportControlFormat->getCharHidden(),ITEMID_CHARHIDDEN));
342 0 : _rItemSet.Put(SvxTwoLinesItem(_rxReportControlFormat->getCharCombineIsOn(),_rxReportControlFormat->getCharCombinePrefix().toChar(),_rxReportControlFormat->getCharCombineSuffix().toChar(),ITEMID_TWOLINES));
343 0 : SvxUnderlineItem aUnderLineItem(aFont.GetUnderline(),ITEMID_UNDERLINE);
344 0 : aUnderLineItem.SetColor(_rxReportControlFormat->getCharUnderlineColor());
345 0 : _rItemSet.Put(aUnderLineItem);
346 0 : _rItemSet.Put(SvxKerningItem(_rxReportControlFormat->getCharKerning(),ITEMID_KERNING));
347 0 : _rItemSet.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark>(_rxReportControlFormat->getCharEmphasis()),ITEMID_EMPHASISMARK));
348 0 : _rItemSet.Put(SvxCharReliefItem(static_cast<FontRelief>(_rxReportControlFormat->getCharRelief()),ITEMID_CHARRELIEF));
349 0 : _rItemSet.Put(SvxColorItem(::Color(_rxReportControlFormat->getCharColor()),ITEMID_COLOR));
350 0 : _rItemSet.Put(SvxCharRotateItem(_rxReportControlFormat->getCharRotation(),false,ITEMID_CHARROTATE));
351 0 : _rItemSet.Put(SvxCharScaleWidthItem(_rxReportControlFormat->getCharScaleWidth(),ITEMID_CHARSCALE_W));
352 :
353 0 : SvxHorJustifyItem aHorJustifyItem(ITEMID_HORJUSTIFY);
354 0 : aHorJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_PARAADJUST),MID_HORJUST_ADJUST);
355 0 : _rItemSet.Put(aHorJustifyItem);
356 0 : SvxVerJustifyItem aVerJustifyItem(ITEMID_VERJUSTIFY);
357 0 : aVerJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_VERTICALALIGN),MID_HORJUST_ADJUST);
358 0 : _rItemSet.Put(aVerJustifyItem);
359 :
360 0 : uno::Reference< report::XShape> xShape(_rxReportControlFormat,uno::UNO_QUERY);
361 0 : if ( !xShape.is() )
362 0 : _rItemSet.Put(SvxBrushItem(::Color(_rxReportControlFormat->getControlBackground()),ITEMID_BRUSH));
363 :
364 0 : lcl_setFont(_rxReportControlFormat, _rItemSet,ASIAN,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_LANGUAGE_ASIAN,ITEMID_POSTURE_ASIAN,ITEMID_WEIGHT_ASIAN );
365 0 : lcl_setFont(_rxReportControlFormat, _rItemSet,COMPLEX,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_LANGUAGE_COMPLEX,ITEMID_POSTURE_COMPLEX,ITEMID_WEIGHT_COMPLEX );
366 0 : }
367 :
368 :
369 0 : void lcl_pushBack( uno::Sequence< beans::NamedValue >& _out_rProperties, const OUString& _sName, const uno::Any& _rValue )
370 : {
371 0 : sal_Int32 nLen( _out_rProperties.getLength() );
372 0 : _out_rProperties.realloc( nLen + 1 );
373 0 : _out_rProperties[ nLen ] = beans::NamedValue( _sName, _rValue );
374 0 : }
375 :
376 :
377 0 : void lcl_initAwtFont( const Font& _rOriginalFont, const SfxItemSet& _rItemSet, awt::FontDescriptor& _out_rAwtFont,
378 : sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
379 : {
380 0 : Font aNewFont( _rOriginalFont );
381 0 : const SfxPoolItem* pItem( NULL );
382 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nFont,true,&pItem) && pItem->ISA(SvxFontItem))
383 : {
384 0 : const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(pItem);
385 0 : aNewFont.SetName( pFontItem->GetFamilyName());
386 0 : aNewFont.SetStyleName(pFontItem->GetStyleName());
387 0 : aNewFont.SetFamily(pFontItem->GetFamily());
388 0 : aNewFont.SetPitch(pFontItem->GetPitch());
389 0 : aNewFont.SetCharSet(pFontItem->GetCharSet());
390 : }
391 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nFontHeight,true,&pItem) && pItem->ISA(SvxFontHeightItem))
392 : {
393 0 : const SvxFontHeightItem* pFontItem = static_cast<const SvxFontHeightItem*>(pItem);
394 0 : aNewFont.SetHeight(OutputDevice::LogicToLogic(Size(0, pFontItem->GetHeight()), MAP_TWIP, MAP_POINT).Height());
395 : }
396 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nPosture,true,&pItem) && pItem->ISA(SvxPostureItem))
397 : {
398 0 : const SvxPostureItem* pFontItem = static_cast<const SvxPostureItem*>(pItem);
399 0 : aNewFont.SetItalic(pFontItem->GetPosture());
400 : }
401 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( _nWeight,true,&pItem) && pItem->ISA(SvxWeightItem))
402 : {
403 0 : const SvxWeightItem* pFontItem = static_cast<const SvxWeightItem*>(pItem);
404 0 : aNewFont.SetWeight(pFontItem->GetWeight());
405 : }
406 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_WORDLINEMODE,true,&pItem) && pItem->ISA(SvxWordLineModeItem))
407 : {
408 0 : const SvxWordLineModeItem* pFontItem = static_cast<const SvxWordLineModeItem*>(pItem);
409 0 : aNewFont.SetWordLineMode(pFontItem->GetValue());
410 : }
411 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CROSSEDOUT,true,&pItem) && pItem->ISA(SvxCrossedOutItem))
412 : {
413 0 : const SvxCrossedOutItem* pFontItem = static_cast<const SvxCrossedOutItem*>(pItem);
414 0 : aNewFont.SetStrikeout(pFontItem->GetStrikeout());
415 : }
416 :
417 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARROTATE,true,&pItem) && pItem->ISA(SvxCharRotateItem))
418 : {
419 0 : const SvxCharRotateItem* pRotateItem = static_cast<const SvxCharRotateItem*>(pItem);
420 0 : aNewFont.SetOrientation(pRotateItem->GetValue());
421 : }
422 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARSCALE_W,true,&pItem) && pItem->ISA(SvxCharScaleWidthItem))
423 : {
424 0 : const SvxCharScaleWidthItem* pCharItem = static_cast<const SvxCharScaleWidthItem*>(pItem);
425 0 : aNewFont.SetWidthType(VCLUnoHelper::ConvertFontWidth(pCharItem->GetValue()));
426 : }
427 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) && pItem->ISA(SvxUnderlineItem))
428 : {
429 0 : const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
430 0 : aNewFont.SetUnderline(pFontItem->GetLineStyle());
431 : }
432 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) && pItem->ISA(SvxColorItem))
433 : {
434 0 : const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
435 0 : aNewFont.SetColor(pFontItem->GetValue().GetColor());
436 : }
437 :
438 0 : _out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
439 0 : }
440 :
441 :
442 0 : void lcl_itemsToCharProperties( const Font& _rOriginalControlFont,const Font& _rOriginalControlFontAsian,const Font& _rOriginalControlFontComplex, const SfxItemSet& _rItemSet, uno::Sequence< beans::NamedValue >& _out_rProperties )
443 : {
444 0 : const SfxPoolItem* pItem( NULL );
445 :
446 : // create an AWT font
447 0 : awt::FontDescriptor aAwtFont;
448 0 : lcl_initAwtFont( _rOriginalControlFont, _rItemSet, aAwtFont,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_POSTURE, ITEMID_WEIGHT);
449 0 : lcl_pushBack( _out_rProperties, OUString("Font"), uno::makeAny( aAwtFont ) );
450 0 : lcl_initAwtFont( _rOriginalControlFontAsian, _rItemSet, aAwtFont,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_POSTURE_ASIAN, ITEMID_WEIGHT_ASIAN);
451 0 : lcl_pushBack( _out_rProperties, OUString("FontAsian"), uno::makeAny( aAwtFont ) );
452 0 : lcl_initAwtFont( _rOriginalControlFontComplex, _rItemSet, aAwtFont,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_POSTURE_COMPLEX, ITEMID_WEIGHT_COMPLEX);
453 0 : lcl_pushBack( _out_rProperties, OUString("FontComplex"), uno::makeAny( aAwtFont ) );
454 :
455 : // properties which cannot be represented in an AWT font need to be preserved directly
456 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_SHADOWED,true,&pItem) && pItem->ISA(SvxShadowedItem))
457 : {
458 0 : const SvxShadowedItem* pFontItem = static_cast<const SvxShadowedItem*>(pItem);
459 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::makeAny( pFontItem->GetValue() ) );
460 : }
461 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CONTOUR,true,&pItem) && pItem->ISA(SvxContourItem))
462 : {
463 0 : const SvxContourItem* pFontItem = static_cast<const SvxContourItem*>(pItem);
464 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::makeAny( pFontItem->GetValue() ) );
465 : }
466 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_UNDERLINE,true,&pItem) && pItem->ISA(SvxUnderlineItem))
467 : {
468 0 : const SvxUnderlineItem* pFontItem = static_cast<const SvxUnderlineItem*>(pItem);
469 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::makeAny( pFontItem->GetColor().GetColor() ) );
470 : }
471 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_HORJUSTIFY,true,&pItem) && pItem->ISA(SvxHorJustifyItem))
472 : {
473 0 : const SvxHorJustifyItem* pJustifyItem = static_cast<const SvxHorJustifyItem*>(pItem);
474 0 : uno::Any aValue;
475 0 : pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
476 0 : lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
477 : }
478 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_VERJUSTIFY,true,&pItem) && pItem->ISA(SvxVerJustifyItem))
479 : {
480 0 : const SvxVerJustifyItem* pJustifyItem = static_cast<const SvxVerJustifyItem*>(pItem);
481 0 : uno::Any aValue;
482 0 : pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
483 0 : lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
484 : }
485 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARRELIEF,true,&pItem) && pItem->ISA(SvxCharReliefItem))
486 : {
487 0 : const SvxCharReliefItem* pFontItem = static_cast<const SvxCharReliefItem*>(pItem);
488 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEnumValue() ) ) );
489 : }
490 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CHARHIDDEN,true,&pItem) && pItem->ISA(SvxCharHiddenItem))
491 : {
492 0 : const SvxCharHiddenItem* pFontItem = static_cast<const SvxCharHiddenItem*>(pItem);
493 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::makeAny( pFontItem->GetValue() ) );
494 : }
495 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_AUTOKERN,true,&pItem) && pItem->ISA(SvxAutoKernItem))
496 : {
497 0 : const SvxAutoKernItem* pFontItem = static_cast<const SvxAutoKernItem*>(pItem);
498 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::makeAny( pFontItem->GetValue() ) );
499 : }
500 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_BRUSH,true,&pItem) && pItem->ISA(SvxBrushItem))
501 : {
502 0 : const SvxBrushItem* pFontItem = static_cast<const SvxBrushItem*>(pItem);
503 0 : lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::makeAny( pFontItem->GetColor().GetColor() ) );
504 : }
505 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_BLINK,true,&pItem) && pItem->ISA(SvxBlinkItem))
506 : {
507 0 : const SvxBlinkItem* pFontItem = static_cast<const SvxBlinkItem*>(pItem);
508 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::makeAny( pFontItem->GetValue() ) );
509 : }
510 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_EMPHASISMARK,true,&pItem) && pItem->ISA(SvxEmphasisMarkItem))
511 : {
512 0 : const SvxEmphasisMarkItem* pFontItem = static_cast<const SvxEmphasisMarkItem*>(pItem);
513 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::makeAny( static_cast< sal_Int16 >( pFontItem->GetEmphasisMark() ) ) );
514 : }
515 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_TWOLINES,true,&pItem) && pItem->ISA(SvxTwoLinesItem))
516 : {
517 0 : const SvxTwoLinesItem* pFontItem = static_cast<const SvxTwoLinesItem*>(pItem);
518 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::makeAny( pFontItem->GetValue() ) );
519 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::makeAny( OUString( pFontItem->GetStartBracket() ) ) );
520 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::makeAny( OUString( pFontItem->GetEndBracket() ) ) );
521 : }
522 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_COLOR,true,&pItem) && pItem->ISA(SvxColorItem))
523 : {
524 0 : const SvxColorItem* pFontItem = static_cast<const SvxColorItem*>(pItem);
525 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::makeAny( pFontItem->GetValue().GetColor() ) );
526 : }
527 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_KERNING,true,&pItem) && pItem->ISA(SvxKerningItem))
528 : {
529 0 : const SvxKerningItem* pFontItem = static_cast<const SvxKerningItem*>(pItem);
530 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::makeAny( pFontItem->GetValue() ) );
531 : }
532 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CASEMAP,true,&pItem) && pItem->ISA(SvxCaseMapItem))
533 : {
534 0 : const SvxCaseMapItem* pFontItem = static_cast<const SvxCaseMapItem*>(pItem);
535 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::makeAny( pFontItem->GetValue() ) );
536 : }
537 0 : struct Items {
538 : sal_uInt16 nWhich;
539 : OUString sPropertyName;
540 : };
541 : const Items pItems[] = { {ITEMID_LANGUAGE,OUString(PROPERTY_CHARLOCALE)}
542 : ,{ITEMID_LANGUAGE_ASIAN,OUString(PROPERTY_CHARLOCALEASIAN)}
543 : ,{ITEMID_LANGUAGE_COMPLEX,OUString(PROPERTY_CHARLOCALECOMPLEX)}
544 0 : };
545 0 : for(size_t k = 0; k < sizeof(pItems)/sizeof(pItems[0]);++k)
546 : {
547 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( pItems[k].nWhich,true,&pItem) && pItem->ISA(SvxLanguageItem))
548 : {
549 0 : const SvxLanguageItem* pFontItem = static_cast<const SvxLanguageItem*>(pItem);
550 0 : lang::Locale aCharLocale( LanguageTag( pFontItem->GetLanguage()).getLocale());
551 0 : lcl_pushBack( _out_rProperties, pItems[k].sPropertyName, uno::makeAny( aCharLocale ) );
552 : }
553 : }
554 0 : if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_ESCAPEMENT,true,&pItem) && pItem->ISA(SvxEscapementItem))
555 : {
556 0 : const SvxEscapementItem* pFontItem = static_cast<const SvxEscapementItem*>(pItem);
557 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::makeAny( pFontItem->GetEsc() ) );
558 0 : lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::makeAny( (sal_Int8)pFontItem->GetProp() ) );
559 0 : }
560 0 : }
561 :
562 :
563 : template< class ATTRIBUTE_TYPE >
564 0 : void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
565 : const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
566 : void (SAL_CALL report::XReportControlFormat::*pSetter)( ATTRIBUTE_TYPE ) )
567 : {
568 0 : ATTRIBUTE_TYPE aAttributeValue = ATTRIBUTE_TYPE();
569 0 : if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
570 0 : (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
571 0 : }
572 :
573 :
574 0 : void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
575 : const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
576 : void (SAL_CALL report::XReportControlFormat::*pSetter)( const OUString& ) )
577 : {
578 0 : OUString aAttributeValue;
579 0 : if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
580 0 : (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
581 0 : }
582 :
583 :
584 0 : void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const sal_Char* _pAttributeName,
585 : const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
586 : void (SAL_CALL report::XReportControlFormat::*pSetter)( const lang::Locale& ) )
587 : {
588 0 : lang::Locale aAttributeValue;
589 0 : if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
590 0 : (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
591 0 : }
592 : }
593 :
594 :
595 0 : bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
596 : const uno::Reference< awt::XWindow>& _rxParentWindow, uno::Sequence< beans::NamedValue >& _out_rNewValues )
597 : {
598 : OSL_PRECOND( _rxReportControlFormat.is() && _rxParentWindow.is(), "openCharDialog: invalid parameters!" );
599 0 : if ( !_rxReportControlFormat.is() || !_rxParentWindow.is() )
600 0 : return false;
601 :
602 0 : _out_rNewValues = uno::Sequence< beans::NamedValue >();
603 :
604 :
605 : // UNO->ItemSet
606 : static SfxItemInfo aItemInfos[] =
607 : {
608 : { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE },
609 : { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE },
610 : { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE },
611 : { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE },
612 : { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE },
613 : { SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE },
614 : { SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE },
615 : { SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE },
616 : { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE },
617 : { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE },
618 : { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE },
619 : { SID_ATTR_CHAR_KERNING, SFX_ITEM_POOLABLE },
620 : { SID_ATTR_CHAR_CASEMAP, SFX_ITEM_POOLABLE },
621 : { SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEM_POOLABLE },
622 : { SID_ATTR_CHAR_FONTLIST, SFX_ITEM_POOLABLE },
623 : { SID_ATTR_CHAR_AUTOKERN, SFX_ITEM_POOLABLE },
624 : { SID_COLOR_TABLE, SFX_ITEM_POOLABLE },
625 : { SID_ATTR_FLASH, SFX_ITEM_POOLABLE },
626 : { SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE },
627 : { SID_ATTR_CHAR_TWO_LINES, SFX_ITEM_POOLABLE },
628 : { SID_ATTR_CHAR_ROTATED, SFX_ITEM_POOLABLE },
629 : { SID_ATTR_CHAR_SCALEWIDTH, SFX_ITEM_POOLABLE },
630 : { SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE },
631 : { SID_ATTR_CHAR_HIDDEN, SFX_ITEM_POOLABLE },
632 : { SID_ATTR_BRUSH, SFX_ITEM_POOLABLE },
633 : { SID_ATTR_ALIGN_HOR_JUSTIFY, SFX_ITEM_POOLABLE },
634 : { SID_ATTR_ALIGN_VER_JUSTIFY, SFX_ITEM_POOLABLE },
635 :
636 : // Asian
637 : { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE },
638 : { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE },
639 : { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE },
640 : { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE },
641 : { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE },
642 : // Complex
643 : { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE },
644 : { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE },
645 : { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE },
646 : { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE },
647 : { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }
648 : };
649 0 : Window* pParent = VCLUnoHelper::GetWindow( _rxParentWindow );
650 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
651 0 : ::std::auto_ptr<FontList> pFontList(new FontList( pParent ));
652 0 : XColorListRef pColorList( XColorList::CreateStdColorList() );
653 : SAL_WNODEPRECATED_DECLARATIONS_POP
654 : SfxPoolItem* pDefaults[] =
655 : {
656 0 : new SvxFontItem(ITEMID_FONT),
657 0 : new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT),
658 0 : new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE),
659 0 : new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE),
660 0 : new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT),
661 :
662 0 : new SvxShadowedItem(false,ITEMID_SHADOWED),
663 0 : new SvxWordLineModeItem(false,ITEMID_WORDLINEMODE),
664 0 : new SvxContourItem(false,ITEMID_CONTOUR),
665 0 : new SvxCrossedOutItem(STRIKEOUT_NONE,ITEMID_CROSSEDOUT),
666 0 : new SvxUnderlineItem(UNDERLINE_NONE,ITEMID_UNDERLINE),
667 :
668 0 : new SvxColorItem(ITEMID_COLOR),
669 0 : new SvxKerningItem(0,ITEMID_KERNING),
670 0 : new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED,ITEMID_CASEMAP),
671 0 : new SvxEscapementItem(ITEMID_ESCAPEMENT),
672 0 : new SvxFontListItem(pFontList.get(),ITEMID_FONTLIST),
673 0 : new SvxAutoKernItem(false,ITEMID_AUTOKERN),
674 0 : new SvxColorListItem(pColorList.get(),ITEMID_COLOR_TABLE),
675 0 : new SvxBlinkItem(false,ITEMID_BLINK),
676 0 : new SvxEmphasisMarkItem(EMPHASISMARK_NONE,ITEMID_EMPHASISMARK),
677 0 : new SvxTwoLinesItem(true,0,0,ITEMID_TWOLINES),
678 0 : new SvxCharRotateItem(0,false,ITEMID_CHARROTATE),
679 0 : new SvxCharScaleWidthItem(100,ITEMID_CHARSCALE_W),
680 0 : new SvxCharReliefItem(RELIEF_NONE,ITEMID_CHARRELIEF),
681 0 : new SvxCharHiddenItem(false,ITEMID_CHARHIDDEN),
682 0 : new SvxBrushItem(ITEMID_BRUSH),
683 0 : new SvxHorJustifyItem(ITEMID_HORJUSTIFY),
684 0 : new SvxVerJustifyItem(ITEMID_VERJUSTIFY),
685 : // Asian
686 0 : new SvxFontItem(ITEMID_FONT_ASIAN),
687 0 : new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_ASIAN),
688 0 : new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE_ASIAN),
689 0 : new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE_ASIAN),
690 0 : new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT_ASIAN),
691 : // Complex
692 0 : new SvxFontItem(ITEMID_FONT_COMPLEX),
693 0 : new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_COMPLEX),
694 0 : new SvxLanguageItem(LANGUAGE_GERMAN,ITEMID_LANGUAGE_COMPLEX),
695 0 : new SvxPostureItem(ITALIC_NONE,ITEMID_POSTURE_COMPLEX),
696 0 : new SvxWeightItem(WEIGHT_NORMAL,ITEMID_WEIGHT_COMPLEX)
697 :
698 0 : };
699 :
700 : OSL_ASSERT((sizeof(pDefaults)/sizeof(pDefaults[0])) == (sizeof(aItemInfos)/sizeof(aItemInfos[0])));
701 :
702 : static const sal_uInt16 pRanges[] =
703 : {
704 : ITEMID_FONT,ITEMID_WEIGHT_COMPLEX,
705 : 0
706 : };
707 :
708 0 : SfxItemPool* pPool( new SfxItemPool(OUString("ReportCharProperties"), ITEMID_FONT,ITEMID_WEIGHT_COMPLEX, aItemInfos, pDefaults) );
709 : // not needed for font height pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why
710 0 : pPool->FreezeIdRanges(); // the same
711 0 : bool bSuccess = false;
712 : try
713 : {
714 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
715 0 : ::std::auto_ptr<SfxItemSet> pDescriptor( new SfxItemSet( *pPool, pRanges ) );
716 : SAL_WNODEPRECATED_DECLARATIONS_POP
717 0 : lcl_CharPropertiesToItems( _rxReportControlFormat, *pDescriptor );
718 :
719 : { // want the dialog to be destroyed before our set
720 0 : ORptPageDialog aDlg(pParent, pDescriptor.get(), "CharDialog");
721 0 : uno::Reference< report::XShape > xShape( _rxReportControlFormat, uno::UNO_QUERY );
722 0 : if ( xShape.is() )
723 0 : aDlg.RemoveTabPage("background");
724 0 : bSuccess = ( RET_OK == aDlg.Execute() );
725 0 : if ( bSuccess )
726 : {
727 : lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat,WESTERN ),
728 : lcl_getReportControlFont( _rxReportControlFormat,ASIAN ),
729 0 : lcl_getReportControlFont( _rxReportControlFormat,COMPLEX ), *aDlg.GetOutputItemSet(), _out_rNewValues );
730 0 : }
731 0 : }
732 : }
733 0 : catch(uno::Exception&)
734 : {
735 : DBG_UNHANDLED_EXCEPTION();
736 : }
737 :
738 0 : SfxItemPool::Free(pPool);
739 0 : for (sal_uInt16 i=0; i<sizeof(pDefaults)/sizeof(pDefaults[0]); ++i)
740 0 : delete pDefaults[i];
741 :
742 0 : return bSuccess;
743 : }
744 :
745 0 : bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::Reference< awt::XWindow>& _rxParentWindow )
746 : {
747 : OSL_PRECOND( _xShape.is() && _rxParentWindow.is(), "openAreaDialog: invalid parameters!" );
748 0 : if ( !_xShape.is() || !_rxParentWindow.is() )
749 0 : return false;
750 :
751 0 : ::boost::shared_ptr<rptui::OReportModel> pModel = ::reportdesign::OReportDefinition::getSdrModel(_xShape->getSection()->getReportDefinition());
752 :
753 0 : Window* pParent = VCLUnoHelper::GetWindow( _rxParentWindow );
754 :
755 0 : bool bSuccess = false;
756 : try
757 : {
758 0 : SfxItemPool& rItemPool = pModel->GetItemPool();
759 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
760 0 : ::std::auto_ptr<SfxItemSet> pDescriptor( new SfxItemSet( rItemPool, rItemPool.GetFirstWhich(),rItemPool.GetLastWhich() ) );
761 : SAL_WNODEPRECATED_DECLARATIONS_POP
762 0 : lcl_fillShapeToItems(_xShape,*pDescriptor);
763 :
764 : { // want the dialog to be destroyed before our set
765 0 : SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
766 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
767 0 : ::std::auto_ptr<AbstractSvxAreaTabDialog> pDialog(pFact->CreateSvxAreaTabDialog( pParent,pDescriptor.get(),pModel.get(), true ));
768 : SAL_WNODEPRECATED_DECLARATIONS_POP
769 0 : if ( ( bSuccess = ( RET_OK == pDialog->Execute() ) ) )
770 0 : lcl_fillItemsToShape(_xShape,*pDialog->GetOutputItemSet());
771 0 : }
772 : }
773 0 : catch(uno::Exception&)
774 : {
775 : DBG_UNHANDLED_EXCEPTION();
776 : }
777 :
778 0 : return bSuccess;
779 : }
780 :
781 :
782 0 : void applyCharacterSettings( const uno::Reference< report::XReportControlFormat >& _rxReportControlFormat, const uno::Sequence< beans::NamedValue >& _rSettings )
783 : {
784 0 : ::comphelper::NamedValueCollection aSettings( _rSettings );
785 :
786 : try
787 : {
788 0 : awt::FontDescriptor aAwtFont;
789 0 : if ( aSettings.get( "Font" ) >>= aAwtFont )
790 : {
791 0 : OUString sTemp = aAwtFont.Name;
792 0 : aAwtFont.Name = OUString(); // hack to
793 0 : _rxReportControlFormat->setFontDescriptor( aAwtFont );
794 0 : _rxReportControlFormat->setCharFontName( sTemp );
795 : }
796 0 : if ( aSettings.get( "FontAsian" ) >>= aAwtFont )
797 : {
798 0 : OUString sTemp = aAwtFont.Name;
799 0 : aAwtFont.Name = OUString(); // hack to
800 0 : _rxReportControlFormat->setFontDescriptorAsian( aAwtFont );
801 0 : _rxReportControlFormat->setCharFontNameAsian( sTemp );
802 : }
803 0 : if ( aSettings.get( "FontComplex" ) >>= aAwtFont )
804 : {
805 0 : OUString sTemp = aAwtFont.Name;
806 0 : aAwtFont.Name = OUString(); // hack to
807 0 : _rxReportControlFormat->setFontDescriptorComplex( aAwtFont );
808 0 : _rxReportControlFormat->setCharFontNameComplex( sTemp );
809 : }
810 :
811 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARSHADOWED, _rxReportControlFormat, &report::XReportControlFormat::setCharShadowed );
812 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCONTOURED, _rxReportControlFormat, &report::XReportControlFormat::setCharContoured );
813 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARUNDERLINECOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharUnderlineColor );
814 0 : lcl_applyFontAttribute( aSettings, PROPERTY_PARAADJUST, _rxReportControlFormat, &report::XReportControlFormat::setParaAdjust );
815 0 : lcl_applyFontAttribute( aSettings, PROPERTY_VERTICALALIGN, _rxReportControlFormat, &report::XReportControlFormat::setVerticalAlign );
816 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARRELIEF, _rxReportControlFormat, &report::XReportControlFormat::setCharRelief );
817 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARHIDDEN, _rxReportControlFormat, &report::XReportControlFormat::setCharHidden );
818 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARAUTOKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharAutoKerning );
819 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CONTROLBACKGROUND, _rxReportControlFormat, &report::XReportControlFormat::setControlBackground );
820 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARFLASH, _rxReportControlFormat, &report::XReportControlFormat::setCharFlash );
821 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHAREMPHASIS, _rxReportControlFormat, &report::XReportControlFormat::setCharEmphasis );
822 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEISON, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineIsOn );
823 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEPREFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombinePrefix );
824 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINESUFFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineSuffix );
825 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharColor );
826 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharKerning );
827 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARCASEMAP, _rxReportControlFormat, &report::XReportControlFormat::setCharCaseMap );
828 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALE, _rxReportControlFormat, &report::XReportControlFormat::setCharLocale );
829 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapement );
830 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENTHEIGHT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapementHeight );
831 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALEASIAN, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleAsian );
832 0 : lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALECOMPLEX, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleComplex );
833 : }
834 0 : catch( const uno::Exception& )
835 : {
836 : DBG_UNHANDLED_EXCEPTION();
837 0 : }
838 0 : }
839 :
840 :
841 0 : void notifySystemWindow(Window* _pWindow,Window* _pToRegister, ::comphelper::mem_fun1_t<TaskPaneList,Window*> _rMemFunc)
842 : {
843 : OSL_ENSURE(_pWindow,"Window can not be null!");
844 0 : SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : NULL;
845 0 : if ( pSystemWindow )
846 : {
847 0 : _rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
848 : }
849 0 : }
850 :
851 0 : SdrObject* isOver(const Rectangle& _rRect, SdrPage& _rPage, SdrView& _rView, bool _bAllObjects, SdrObject* _pIgnore, sal_Int16 _nIgnoreType)
852 : {
853 0 : SdrObject* pOverlappedObj = NULL;
854 0 : SdrObjListIter aIter(_rPage,IM_DEEPNOGROUPS);
855 0 : SdrObject* pObjIter = NULL;
856 :
857 0 : while( !pOverlappedObj && (pObjIter = aIter.Next()) != NULL )
858 : {
859 0 : if ( _pIgnore != pObjIter
860 0 : && (_bAllObjects || !_rView.IsObjMarked(pObjIter))
861 0 : && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL))
862 : {
863 0 : if (_nIgnoreType == ISOVER_IGNORE_CUSTOMSHAPES && pObjIter->GetObjIdentifier() == OBJ_CUSTOMSHAPE)
864 : {
865 0 : continue;
866 : }
867 :
868 0 : if (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL)
869 : {
870 0 : Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
871 0 : if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
872 0 : pOverlappedObj = pObjIter;
873 : }
874 : }
875 : }
876 0 : return pOverlappedObj;
877 : }
878 :
879 0 : bool checkArrayForOccurrence(SdrObject* _pObjToCheck, SdrUnoObj* _pIgnore[], int _nListLength)
880 : {
881 0 : for(int i=0;i<_nListLength;i++)
882 : {
883 0 : SdrObject *pIgnore = _pIgnore[i];
884 0 : if (pIgnore == _pObjToCheck)
885 : {
886 0 : return true;
887 : }
888 : }
889 0 : return false;
890 : }
891 :
892 0 : SdrObject* isOver(const Rectangle& _rRect,SdrPage& _rPage,SdrView& _rView,bool _bAllObjects, SdrUnoObj * _pIgnoreList[], int _nIgnoreListLength)
893 : {
894 0 : SdrObject* pOverlappedObj = NULL;
895 0 : SdrObjListIter aIter(_rPage,IM_DEEPNOGROUPS);
896 0 : SdrObject* pObjIter = NULL;
897 :
898 0 : while( !pOverlappedObj && (pObjIter = aIter.Next()) != NULL )
899 : {
900 0 : if (checkArrayForOccurrence(pObjIter, _pIgnoreList, _nIgnoreListLength))
901 : {
902 0 : continue;
903 : }
904 :
905 0 : if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter))
906 0 : && (dynamic_cast<OUnoObject*>(pObjIter) != NULL || dynamic_cast<OOle2Obj*>(pObjIter) != NULL) )
907 : {
908 0 : Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
909 0 : if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
910 0 : pOverlappedObj = pObjIter;
911 : }
912 : }
913 0 : return pOverlappedObj;
914 : }
915 :
916 :
917 0 : SdrObject* isOver(SdrObject* _pObj,SdrPage& _rPage,SdrView& _rView,bool _bUnMarkedObjects)
918 : {
919 0 : SdrObject* pOverlappedObj = NULL;
920 0 : if (dynamic_cast<OUnoObject*>(_pObj) != NULL || dynamic_cast<OOle2Obj*>(_pObj) != NULL) // this doesn't need to be done for shapes
921 : {
922 0 : Rectangle aRect = _pObj->GetCurrentBoundRect();
923 0 : pOverlappedObj = isOver(aRect,_rPage,_rView,_bUnMarkedObjects,_pObj);
924 : }
925 0 : return pOverlappedObj;
926 : }
927 :
928 :
929 0 : uno::Sequence< OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet )
930 : {
931 0 : uno::Sequence< OUString > aNames;
932 :
933 : try
934 : {
935 0 : uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW );
936 0 : uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() );
937 0 : if ( xParams.is() )
938 : {
939 0 : sal_Int32 count( xParams->getCount() );
940 0 : aNames.realloc( count );
941 :
942 0 : uno::Reference< beans::XPropertySet > xParam;
943 0 : OUString sParamName;
944 0 : for ( sal_Int32 i=0; i<count; ++i )
945 : {
946 0 : xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
947 0 : OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName );
948 0 : aNames[i] = sParamName;
949 0 : }
950 0 : }
951 : }
952 0 : catch( const uno::Exception& )
953 : {
954 : DBG_UNHANDLED_EXCEPTION();
955 : }
956 :
957 0 : return aNames;
958 : }
959 :
960 0 : Rectangle getRectangleFromControl(SdrObject* _pControl)
961 : {
962 0 : if (_pControl)
963 : {
964 0 : uno::Reference< report::XReportComponent > xComponent( _pControl->getUnoShape(), uno::UNO_QUERY);
965 0 : if (xComponent.is())
966 : {
967 0 : Rectangle aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
968 0 : aRect.setHeight(aRect.getHeight() + 1);
969 0 : aRect.setWidth(aRect.getWidth() + 1);
970 0 : return aRect;
971 0 : }
972 : }
973 0 : return Rectangle();
974 : }
975 :
976 : // check overlapping
977 0 : void correctOverlapping(SdrObject* _pControl,OReportSection& _aReportSection,bool _bInsert)
978 : {
979 0 : OSectionView& rSectionView = _aReportSection.getSectionView();
980 0 : uno::Reference< report::XReportComponent> xComponent(_pControl->getUnoShape(),uno::UNO_QUERY);
981 0 : Rectangle aRect = getRectangleFromControl(_pControl);
982 :
983 0 : bool bOverlapping = true;
984 0 : while ( bOverlapping )
985 : {
986 0 : SdrObject* pOverlappedObj = isOver(aRect,*_aReportSection.getPage(),rSectionView,true, _pControl);
987 0 : bOverlapping = pOverlappedObj != NULL;
988 0 : if ( bOverlapping )
989 : {
990 0 : const Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
991 0 : aRect.Move(0,aLogicRect.Top() + aLogicRect.getHeight() - aRect.Top());
992 0 : xComponent->setPositionY(aRect.Top());
993 : }
994 : }
995 0 : if ( !bOverlapping && _bInsert ) // now insert objects
996 0 : rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(),SDRINSERT_ADDMARK);
997 0 : }
998 :
999 0 : void setZoomFactor(const Fraction& _aZoom,Window& _rWindow)
1000 : {
1001 0 : MapMode aMapMode( _rWindow.GetMapMode() );
1002 0 : aMapMode.SetScaleX(_aZoom);
1003 0 : aMapMode.SetScaleY(_aZoom);
1004 0 : _rWindow.SetMapMode(aMapMode);
1005 0 : }
1006 :
1007 0 : bool openDialogFormula_nothrow( OUString& _in_out_rFormula
1008 : , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _xContext
1009 : , const uno::Reference< awt::XWindow>& _xInspectorWindow
1010 : , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet
1011 : )
1012 : {
1013 : OSL_PRECOND( _xInspectorWindow.is(), "openDialogFormula_nothrow: invalid parameters!" );
1014 0 : if ( !_xInspectorWindow.is() )
1015 0 : return false;
1016 0 : bool bSuccess = false;
1017 0 : ::dbtools::SQLExceptionInfo aErrorInfo;
1018 0 : uno::Reference< awt::XWindow > xInspectorWindow;
1019 0 : uno::Reference< lang::XMultiComponentFactory > xFactory;
1020 0 : uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
1021 : try
1022 : {
1023 0 : xFactory = _xContext->getServiceManager();
1024 0 : xServiceFactory.set(xFactory,uno::UNO_QUERY);
1025 0 : Window* pParent = VCLUnoHelper::GetWindow( _xInspectorWindow );
1026 :
1027 0 : uno::Reference< report::meta::XFunctionManager> xMgr(xFactory->createInstanceWithContext("org.libreoffice.report.pentaho.SOFunctionManager",_xContext),uno::UNO_QUERY);
1028 0 : if ( xMgr.is() )
1029 : {
1030 0 : ::boost::shared_ptr< formula::IFunctionManager > pFormulaManager(new FunctionManager(xMgr) );
1031 0 : ReportFormula aFormula( _in_out_rFormula );
1032 0 : FormulaDialog aDlg(pParent,xServiceFactory,pFormulaManager,aFormula.getUndecoratedContent(),_xRowSet);
1033 0 : bSuccess = aDlg.Execute() == RET_OK;
1034 0 : if ( bSuccess )
1035 : {
1036 0 : OUString sFormula = aDlg.getCurrentFormula();
1037 0 : if ( sFormula[0] == '=' )
1038 0 : _in_out_rFormula = "rpt:" + sFormula.copy(1);
1039 : else
1040 0 : _in_out_rFormula = "rpt:" + sFormula;
1041 0 : }
1042 0 : }
1043 : }
1044 0 : catch (const sdb::SQLContext& e) { aErrorInfo = e; }
1045 0 : catch (const sdbc::SQLWarning& e) { aErrorInfo = e; }
1046 0 : catch (const sdbc::SQLException& e) { aErrorInfo = e; }
1047 0 : catch( const uno::Exception& )
1048 : {
1049 : OSL_FAIL( "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1050 : }
1051 :
1052 0 : if ( aErrorInfo.isValid() )
1053 0 : ::dbtools::showError( aErrorInfo, xInspectorWindow, _xContext );
1054 :
1055 0 : return bSuccess;
1056 : }
1057 :
1058 0 : } // namespace rptui
1059 :
1060 :
1061 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|