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