LibreOffice Module reportdesign (master) 1
UITools.cxx
Go to the documentation of this file.
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 <memory>
24#include <SectionView.hxx>
25#include <UITools.hxx>
26#include <Formula.hxx>
27#include <FunctionHelper.hxx>
28#include <reportformula.hxx>
29
31
32#include <vcl/settings.hxx>
33#include <vcl/syswin.hxx>
34#include <vcl/svapp.hxx>
35#include <vcl/unohelp.hxx>
36#include <vcl/window.hxx>
37
38#include <com/sun/star/lang/NullPointerException.hpp>
39#include <com/sun/star/beans/NamedValue.hpp>
40#include <com/sun/star/beans/PropertyAttribute.hpp>
41#include <svx/svdpool.hxx>
42
44#include <editeng/brushitem.hxx>
45#include <editeng/fontitem.hxx>
47#include <editeng/postitem.hxx>
48#include <editeng/udlnitem.hxx>
51#include <editeng/langitem.hxx>
52#include <editeng/wghtitem.hxx>
53#include <editeng/fhgtitem.hxx>
54#include <editeng/shdditem.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>
62#include <editeng/colritem.hxx>
64#include <svx/drawitem.hxx>
69#include <editeng/memberids.h>
70#include <svx/xgrscit.hxx>
71#include <svx/svditer.hxx>
72#include <svx/xtable.hxx>
73#include <svx/svdview.hxx>
74#include <svx/svdpage.hxx>
75#include <svx/svxdlg.hxx>
76#include <svx/unoprov.hxx>
77#include <svx/svxids.hrc>
78
80#include <svtools/ctrltool.hxx>
81#include <svl/itempool.hxx>
82#include <svl/itemset.hxx>
84
87
90
91#include <com/sun/star/style/VerticalAlignment.hpp>
92#include <com/sun/star/report/XShape.hpp>
93#include <com/sun/star/sdb/XParametersSupplier.hpp>
94#include <com/sun/star/sdb/SQLContext.hpp>
96#include <dlgpage.hxx>
97#include <strings.hxx>
98#include <core_resource.hxx>
99#include <RptObject.hxx>
100#include <RptDef.hxx>
101#include <strings.hrc>
102#include <ReportDefinition.hxx>
103#include <RptModel.hxx>
104
105#include <svx/xflbckit.hxx>
106#include <svx/xflbmpit.hxx>
107#include <svx/xflbmsli.hxx>
108#include <svx/xflbmsxy.hxx>
109#include <svx/xflbmtit.hxx>
110#include <svx/xflboxy.hxx>
111#include <svx/xflbstit.hxx>
112#include <svx/xflbtoxy.hxx>
113
114#include <svx/xbtmpit.hxx>
115#include <svx/xfillit0.hxx>
116#include <svx/xfltrit.hxx>
117#include <svx/xflclit.hxx>
118#include <svx/xflgrit.hxx>
119#include <svx/xflhtit.hxx>
120#include <svx/xflftrit.hxx>
121#include <svx/xsflclit.hxx>
122
125#define ITEMID_FIRST XATTR_FILL_LAST
126
127#define ITEMID_FONT TypedWhichId<SvxFontItem>(ITEMID_FIRST)
128#define ITEMID_FONTHEIGHT TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 1)
129#define ITEMID_LANGUAGE TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 2)
130
131#define ITEMID_POSTURE TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 3)
132#define ITEMID_WEIGHT TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 4)
133#define ITEMID_SHADOWED TypedWhichId<SvxShadowedItem>(ITEMID_FIRST + 5)
134#define ITEMID_WORDLINEMODE TypedWhichId<SvxWordLineModeItem>(ITEMID_FIRST + 6)
135#define ITEMID_CONTOUR TypedWhichId<SvxContourItem>(ITEMID_FIRST + 7)
136#define ITEMID_CROSSEDOUT TypedWhichId<SvxCrossedOutItem>(ITEMID_FIRST + 8)
137#define ITEMID_UNDERLINE TypedWhichId<SvxUnderlineItem>(ITEMID_FIRST + 9)
138
139#define ITEMID_COLOR TypedWhichId<SvxColorItem>(ITEMID_FIRST + 10)
140#define ITEMID_KERNING TypedWhichId<SvxKerningItem>(ITEMID_FIRST + 11)
141#define ITEMID_CASEMAP TypedWhichId<SvxCaseMapItem>(ITEMID_FIRST + 12)
142
143#define ITEMID_ESCAPEMENT TypedWhichId<SvxEscapementItem>(ITEMID_FIRST + 13)
144#define ITEMID_FONTLIST ITEMID_FIRST + 14
145#define ITEMID_AUTOKERN TypedWhichId<SvxAutoKernItem>(ITEMID_FIRST + 15)
146#define ITEMID_COLOR_TABLE TypedWhichId<SvxColorListItem>(ITEMID_FIRST + 16)
147#define ITEMID_BLINK TypedWhichId<SvxBlinkItem>(ITEMID_FIRST + 17)
148#define ITEMID_EMPHASISMARK TypedWhichId<SvxEmphasisMarkItem>(ITEMID_FIRST + 18)
149#define ITEMID_TWOLINES TypedWhichId<SvxTwoLinesItem>(ITEMID_FIRST + 19)
150#define ITEMID_CHARROTATE TypedWhichId<SvxCharRotateItem>(ITEMID_FIRST + 20)
151#define ITEMID_CHARSCALE_W TypedWhichId<SvxCharScaleWidthItem>(ITEMID_FIRST + 21)
152#define ITEMID_CHARRELIEF TypedWhichId<SvxCharReliefItem>(ITEMID_FIRST + 22)
153#define ITEMID_CHARHIDDEN TypedWhichId<SvxCharHiddenItem>(ITEMID_FIRST + 23)
154#define ITEMID_BRUSH TypedWhichId<SvxBrushItem>(ITEMID_FIRST + 24)
155#define ITEMID_HORJUSTIFY TypedWhichId<SvxHorJustifyItem>(ITEMID_FIRST + 25)
156#define ITEMID_VERJUSTIFY TypedWhichId<SvxVerJustifyItem>(ITEMID_FIRST + 26)
157#define ITEMID_FONT_ASIAN TypedWhichId<SvxFontItem>(ITEMID_FIRST + 27)
158#define ITEMID_FONTHEIGHT_ASIAN TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 28)
159#define ITEMID_LANGUAGE_ASIAN TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 29)
160#define ITEMID_POSTURE_ASIAN TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 30)
161#define ITEMID_WEIGHT_ASIAN TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 31)
162#define ITEMID_FONT_COMPLEX TypedWhichId<SvxFontItem>(ITEMID_FIRST + 32)
163#define ITEMID_FONTHEIGHT_COMPLEX TypedWhichId<SvxFontHeightItem>(ITEMID_FIRST + 33)
164#define ITEMID_LANGUAGE_COMPLEX TypedWhichId<SvxLanguageItem>(ITEMID_FIRST + 34)
165#define ITEMID_POSTURE_COMPLEX TypedWhichId<SvxPostureItem>(ITEMID_FIRST + 35)
166#define ITEMID_WEIGHT_COMPLEX TypedWhichId<SvxWeightItem>(ITEMID_FIRST + 36)
167
168#define WESTERN 0
169#define ASIAN 1
170#define COMPLEX 2
171
172namespace rptui
173{
174using namespace ::com::sun::star;
175using namespace formula;
176
177void adjustSectionName(const uno::Reference< report::XGroup >& _xGroup,sal_Int32 _nPos)
178{
179 OSL_ENSURE(_xGroup.is(),"Group is NULL -> GPF");
180 if ( _xGroup->getHeaderOn() && _xGroup->getHeader()->getName().isEmpty() )
181 {
182 OUString sName = RptResId(RID_STR_GROUPHEADER) + OUString::number(_nPos);
183 _xGroup->getHeader()->setName(sName);
184 }
185
186 if ( _xGroup->getFooterOn() && _xGroup->getFooter()->getName().isEmpty() )
187 {
188 OUString sName = RptResId(RID_STR_GROUPFOOTER) + OUString::number(_nPos);
189 _xGroup->getFooter()->setName(sName);
190 }
191}
192
193::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener(const uno::Reference< report::XReportDefinition >& _xReportDefinition,::comphelper::OPropertyChangeListener* _pListener)
194{
196 if ( _xReportDefinition.is() )
197 {
198 uno::Reference<beans::XPropertySet> xPageStyle(getUsedStyle(_xReportDefinition),uno::UNO_QUERY);
199 if ( xPageStyle.is() )
200 {
201 pRet = new comphelper::OPropertyChangeMultiplexer(_pListener,xPageStyle);
202 pRet->addProperty(PROPERTY_LEFTMARGIN);
203 pRet->addProperty(PROPERTY_RIGHTMARGIN);
204 pRet->addProperty(PROPERTY_PAPERSIZE);
205 pRet->addProperty(PROPERTY_BACKCOLOR);
206 }
207 }
208 return pRet;
209}
210
211
212namespace
213{
214
215 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat, awt::FontDescriptor& _out_rControlFont ,sal_uInt16 _nWichFont)
216 {
217 if ( !_rxReportControlFormat.is() )
218 throw uno::RuntimeException();
219
220 switch(_nWichFont)
221 {
222 case WESTERN:
223 _out_rControlFont = _rxReportControlFormat->getFontDescriptor();
224 break;
225 case ASIAN:
226 _out_rControlFont = _rxReportControlFormat->getFontDescriptorAsian();
227 break;
228 case COMPLEX:
229 _out_rControlFont = _rxReportControlFormat->getFontDescriptorComplex();
230 break;
231
232 }
233
235 return VCLUnoHelper::CreateFont( _out_rControlFont, aDefaultFont );
236 }
237
238
239 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,sal_uInt16 _nWhich )
240 {
241 awt::FontDescriptor aAwtFont;
242 return lcl_getReportControlFont( _rxReportControlFormat, aAwtFont, _nWhich );
243 }
244
245 vcl::Font lcl_setFont(const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
246 SfxItemSet& _rItemSet,sal_uInt16 _nWhich,sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nLanguage,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
247 {
248 // fill it
249 awt::FontDescriptor aControlFont;
250 const vcl::Font aFont( lcl_getReportControlFont( _rxReportControlFormat, aControlFont,_nWhich ) );
251
252 SvxFontItem aFontItem(_nFont);
253 aFontItem.PutValue( uno::Any( aControlFont ), 0 );
254 _rItemSet.Put(aFontItem);
255
256 _rItemSet.Put(SvxFontHeightItem(o3tl::convert(aFont.GetFontHeight(), o3tl::Length::pt, o3tl::Length::twip), 100, _nFontHeight));
257 lang::Locale aLocale;
258 switch(_nWhich)
259 {
260 default:
261 aLocale = _rxReportControlFormat->getCharLocale();
262 break;
263 case ASIAN:
264 aLocale = _rxReportControlFormat->getCharLocaleAsian();
265 break;
266 case COMPLEX:
267 aLocale = _rxReportControlFormat->getCharLocaleComplex();
268 break;
269 }
270
271 _rItemSet.Put(SvxLanguageItem(LanguageTag(aLocale).makeFallback().getLanguageType(),_nLanguage));
272
273 _rItemSet.Put(SvxPostureItem(aFont.GetItalic(),_nPosture));
274 _rItemSet.Put(SvxWeightItem(aFont.GetWeight(),_nWeight));
275 return aFont;
276 }
277
278 void lcl_fillShapeToItems( const uno::Reference<report::XShape >& _xShape,SfxItemSet& _rItemSet )
279 {
280 uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
282 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
283 for (const auto pProp : rPropertyMap.getPropertyEntries())
284 {
285 if ( xInfo->hasPropertyByName(pProp->aName) )
286 {
287 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
288 if ( pItem )
289 {
290 ::std::unique_ptr<SfxPoolItem> pClone(pItem->CloneSetWhich(pProp->nWID));
291 pClone->PutValue(_xShape->getPropertyValue(pProp->aName), pProp->nMemberId);
292 _rItemSet.Put(std::move(pClone));
293 }
294 }
295 }
296 }
297
298 void lcl_fillItemsToShape( const uno::Reference<report::XShape >& _xShape,const SfxItemSet& _rItemSet )
299 {
300 const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
302 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
303 for (const auto pProp : rPropertyMap.getPropertyEntries())
304 {
305 if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID) && xInfo->hasPropertyByName(pProp->aName) )
306 {
307 if ( ( pProp->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
308 {
309 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
310 if ( pItem )
311 {
312 uno::Any aValue;
313 pItem->QueryValue(aValue, pProp->nMemberId);
314 try
315 {
316 _xShape->setPropertyValue(pProp->aName, aValue);
317 }
318 catch(uno::Exception&)
319 { // shapes have a bug so we ignore this one.
320 }
321 }
322 }
323 }
324 }
325 }
326
327 void lcl_CharPropertiesToItems( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
328 SfxItemSet& _rItemSet )
329 {
330 if ( !_rxReportControlFormat.is() )
331 throw lang::NullPointerException();
332
333 uno::Reference< beans::XPropertySet > xSet(_rxReportControlFormat,uno::UNO_QUERY_THROW);
334
335 // fill it
336 const vcl::Font aFont( lcl_setFont(_rxReportControlFormat, _rItemSet,WESTERN,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_LANGUAGE,ITEMID_POSTURE,ITEMID_WEIGHT ) );
337
338 _rItemSet.Put(SvxShadowedItem(_rxReportControlFormat->getCharShadowed(),ITEMID_SHADOWED));
339 _rItemSet.Put(SvxWordLineModeItem(aFont.IsWordLineMode(),ITEMID_WORDLINEMODE));
340 _rItemSet.Put(SvxContourItem(_rxReportControlFormat->getCharContoured(),ITEMID_CONTOUR));
341 _rItemSet.Put(SvxAutoKernItem(_rxReportControlFormat->getCharAutoKerning(),ITEMID_AUTOKERN));
342 _rItemSet.Put(SvxCrossedOutItem(aFont.GetStrikeout(),ITEMID_CROSSEDOUT));
343 _rItemSet.Put(SvxCaseMapItem(static_cast<SvxCaseMap>(_rxReportControlFormat->getCharCaseMap()),ITEMID_CASEMAP));
344
345 _rItemSet.Put(SvxEscapementItem(_rxReportControlFormat->getCharEscapement(),_rxReportControlFormat->getCharEscapementHeight(),ITEMID_ESCAPEMENT));
346 _rItemSet.Put(SvxBlinkItem(_rxReportControlFormat->getCharFlash(),ITEMID_BLINK));
347 _rItemSet.Put(SvxCharHiddenItem(_rxReportControlFormat->getCharHidden(),ITEMID_CHARHIDDEN));
348 _rItemSet.Put(SvxTwoLinesItem(_rxReportControlFormat->getCharCombineIsOn(),_rxReportControlFormat->getCharCombinePrefix().toChar(),_rxReportControlFormat->getCharCombineSuffix().toChar(),ITEMID_TWOLINES));
349 SvxUnderlineItem aUnderLineItem(aFont.GetUnderline(),ITEMID_UNDERLINE);
350 aUnderLineItem.SetColor(Color(ColorTransparency, _rxReportControlFormat->getCharUnderlineColor()));
351 _rItemSet.Put(aUnderLineItem);
352 _rItemSet.Put(SvxKerningItem(_rxReportControlFormat->getCharKerning(),ITEMID_KERNING));
353 _rItemSet.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark>(_rxReportControlFormat->getCharEmphasis()),ITEMID_EMPHASISMARK));
354 _rItemSet.Put(SvxCharReliefItem(static_cast<FontRelief>(_rxReportControlFormat->getCharRelief()),ITEMID_CHARRELIEF));
355 _rItemSet.Put(SvxColorItem(::Color(ColorTransparency, _rxReportControlFormat->getCharColor()),ITEMID_COLOR));
356 _rItemSet.Put(SvxCharRotateItem(Degree10(_rxReportControlFormat->getCharRotation()),false,ITEMID_CHARROTATE));
357 _rItemSet.Put(SvxCharScaleWidthItem(_rxReportControlFormat->getCharScaleWidth(),ITEMID_CHARSCALE_W));
358
359 SvxHorJustifyItem aHorJustifyItem(ITEMID_HORJUSTIFY);
360 aHorJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_PARAADJUST),MID_HORJUST_ADJUST);
361 _rItemSet.Put(aHorJustifyItem);
362 SvxVerJustifyItem aVerJustifyItem(ITEMID_VERJUSTIFY);
363 aVerJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_VERTICALALIGN),MID_HORJUST_ADJUST);
364 _rItemSet.Put(aVerJustifyItem);
365
366 uno::Reference< report::XShape> xShape(_rxReportControlFormat,uno::UNO_QUERY);
367 if ( !xShape.is() )
368 _rItemSet.Put(SvxBrushItem(::Color(ColorTransparency, _rxReportControlFormat->getControlBackground()),ITEMID_BRUSH));
369
372 }
373
374
375 void lcl_pushBack( uno::Sequence< beans::NamedValue >& _out_rProperties, const OUString& _sName, const uno::Any& _rValue )
376 {
377 sal_Int32 nLen( _out_rProperties.getLength() );
378 _out_rProperties.realloc( nLen + 1 );
379 _out_rProperties.getArray()[ nLen ] = beans::NamedValue( _sName, _rValue );
380 }
381
382
383 void lcl_initAwtFont( const vcl::Font& _rOriginalFont, const SfxItemSet& _rItemSet, awt::FontDescriptor& _out_rAwtFont,
386 {
387 vcl::Font aNewFont( _rOriginalFont );
388 if ( const SvxFontItem* pFontItem = _rItemSet.GetItemIfSet( _nFont) )
389 {
390 aNewFont.SetFamilyName(pFontItem->GetFamilyName());
391 aNewFont.SetStyleName(pFontItem->GetStyleName());
392 aNewFont.SetFamily(pFontItem->GetFamily());
393 aNewFont.SetPitch(pFontItem->GetPitch());
394 aNewFont.SetCharSet(pFontItem->GetCharSet());
395 }
396 if ( const SvxFontHeightItem* pFontItem = _rItemSet.GetItemIfSet( _nFontHeight ) )
397 {
398 aNewFont.SetFontHeight(o3tl::convert(pFontItem->GetHeight(), o3tl::Length::twip, o3tl::Length::pt));
399 }
400 if ( const SvxPostureItem* pPostureItem = _rItemSet.GetItemIfSet( _nPosture) )
401 {
402 aNewFont.SetItalic(pPostureItem->GetPosture());
403 }
404 if ( const SvxWeightItem* pWeightItem = _rItemSet.GetItemIfSet( _nWeight ) )
405 {
406 aNewFont.SetWeight(pWeightItem->GetWeight());
407 }
408 if ( const SvxWordLineModeItem* pWordLineItem = _rItemSet.GetItemIfSet( ITEMID_WORDLINEMODE ) )
409 {
410 aNewFont.SetWordLineMode(pWordLineItem->GetValue());
411 }
412 if ( const SvxCrossedOutItem* pCrossedOutItem = _rItemSet.GetItemIfSet( ITEMID_CROSSEDOUT ) )
413 {
414 aNewFont.SetStrikeout(pCrossedOutItem->GetStrikeout());
415 }
416 if ( const SvxCharRotateItem* pRotateItem = _rItemSet.GetItemIfSet( ITEMID_CHARROTATE ) )
417 {
418 aNewFont.SetOrientation(pRotateItem->GetValue());
419 }
420 if ( const SvxCharScaleWidthItem* pCharItem = _rItemSet.GetItemIfSet( ITEMID_CHARSCALE_W ) )
421 {
422 aNewFont.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem->GetValue()));
423 }
424 if ( const SvxUnderlineItem* pUnderlineItem = _rItemSet.GetItemIfSet( ITEMID_UNDERLINE ) )
425 {
426 aNewFont.SetUnderline(pUnderlineItem->GetLineStyle());
427 }
428 if ( const SvxColorItem* pColorItem = _rItemSet.GetItemIfSet( ITEMID_COLOR ) )
429 {
430 aNewFont.SetColor(pColorItem->GetValue());
431 }
432
433 _out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
434 }
435
436
437 void lcl_itemsToCharProperties( const vcl::Font& _rOriginalControlFont,const vcl::Font& _rOriginalControlFontAsian,const vcl::Font& _rOriginalControlFontComplex, const SfxItemSet& _rItemSet, uno::Sequence< beans::NamedValue >& _out_rProperties )
438 {
439 // create an AWT font
440 awt::FontDescriptor aAwtFont;
441 lcl_initAwtFont( _rOriginalControlFont, _rItemSet, aAwtFont,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_POSTURE, ITEMID_WEIGHT);
442 lcl_pushBack( _out_rProperties, "Font", uno::Any( aAwtFont ) );
443 lcl_initAwtFont( _rOriginalControlFontAsian, _rItemSet, aAwtFont,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_POSTURE_ASIAN, ITEMID_WEIGHT_ASIAN);
444 lcl_pushBack( _out_rProperties, "FontAsian", uno::Any( aAwtFont ) );
445 lcl_initAwtFont( _rOriginalControlFontComplex, _rItemSet, aAwtFont,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_POSTURE_COMPLEX, ITEMID_WEIGHT_COMPLEX);
446 lcl_pushBack( _out_rProperties, "FontComplex", uno::Any( aAwtFont ) );
447
448 // properties which cannot be represented in an AWT font need to be preserved directly
449 if ( const SvxShadowedItem* pShadowedItem = _rItemSet.GetItemIfSet( ITEMID_SHADOWED) )
450 lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::Any( pShadowedItem->GetValue() ) );
451 if ( const SvxContourItem* pContourItem = _rItemSet.GetItemIfSet( ITEMID_CONTOUR ) )
452 lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::Any( pContourItem->GetValue() ) );
453 if ( const SvxUnderlineItem* pUnderlineItem = _rItemSet.GetItemIfSet( ITEMID_UNDERLINE ) )
454 lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::Any( pUnderlineItem->GetColor() ) );
455 if ( const SvxHorJustifyItem* pJustifyItem = _rItemSet.GetItemIfSet( ITEMID_HORJUSTIFY ) )
456 {
457 uno::Any aValue;
458 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
459 lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
460 }
461 if ( const SvxVerJustifyItem* pJustifyItem = _rItemSet.GetItemIfSet( ITEMID_VERJUSTIFY ) )
462 {
463 uno::Any aValue;
464 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
465 lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
466 }
467 if ( const SvxCharReliefItem* pReliefItem = _rItemSet.GetItemIfSet( ITEMID_CHARRELIEF ) )
468 lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::Any( static_cast< sal_Int16 >( pReliefItem->GetEnumValue() ) ) );
469 if ( const SvxCharHiddenItem* pHiddenItem = _rItemSet.GetItemIfSet( ITEMID_CHARHIDDEN ) )
470 lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::Any( pHiddenItem->GetValue() ) );
471 if ( const SvxAutoKernItem* pKernItem = _rItemSet.GetItemIfSet( ITEMID_AUTOKERN ) )
472 lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::Any( pKernItem->GetValue() ) );
473 if ( const SvxBrushItem* pBrushItem = _rItemSet.GetItemIfSet( ITEMID_BRUSH ) )
474 lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::Any( pBrushItem->GetColor() ) );
475 if ( const SvxBlinkItem* pBlinkItem = _rItemSet.GetItemIfSet( ITEMID_BLINK ) )
476 lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::Any( pBlinkItem->GetValue() ) );
477 if ( const SvxEmphasisMarkItem* pMarkItem = _rItemSet.GetItemIfSet( ITEMID_EMPHASISMARK ) )
478 lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::Any( static_cast< sal_Int16 >( pMarkItem->GetEmphasisMark() ) ) );
479 if ( const SvxTwoLinesItem* pLinesItem = _rItemSet.GetItemIfSet( ITEMID_TWOLINES ) )
480 {
481 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::Any( pLinesItem->GetValue() ) );
482 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::Any( OUString( pLinesItem->GetStartBracket() ) ) );
483 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::Any( OUString( pLinesItem->GetEndBracket() ) ) );
484 }
485 if ( const SvxColorItem* pColorItem = _rItemSet.GetItemIfSet( ITEMID_COLOR ) )
486 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::Any( pColorItem->GetValue() ) );
487 if ( const SvxKerningItem* pKernItem = _rItemSet.GetItemIfSet( ITEMID_KERNING ) )
488 lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::Any( pKernItem->GetValue() ) );
489 if ( const SvxCaseMapItem* pCaseMapItem = _rItemSet.GetItemIfSet( ITEMID_CASEMAP ) )
490 lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::Any( pCaseMapItem->GetEnumValue() ) );
491 struct Items {
493 OUString sPropertyName;
494 };
495 const Items pItems[] = { {ITEMID_LANGUAGE,OUString(PROPERTY_CHARLOCALE)}
498 };
499 for(const auto & k : pItems)
500 {
501 if ( const SvxLanguageItem* pLanguageItem = _rItemSet.GetItemIfSet( k.nWhich ) )
502 {
503 lang::Locale aCharLocale( LanguageTag( pLanguageItem->GetLanguage()).getLocale());
504 lcl_pushBack( _out_rProperties, k.sPropertyName, uno::Any( aCharLocale ) );
505 }
506 }
507 if ( const SvxEscapementItem* pEscapementItem = _rItemSet.GetItemIfSet( ITEMID_ESCAPEMENT ) )
508 {
509 lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::Any( pEscapementItem->GetEsc() ) );
510 lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::Any(static_cast<sal_Int8>(pEscapementItem->GetProportionalHeight())) );
511 }
512 }
513
514
515 template< class ATTRIBUTE_TYPE >
516 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
517 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
518 void (SAL_CALL report::XReportControlFormat::*pSetter)( ATTRIBUTE_TYPE ) )
519 {
520 ATTRIBUTE_TYPE aAttributeValue = ATTRIBUTE_TYPE();
521 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
522 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
523 }
524
525
526 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
527 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
528 void (SAL_CALL report::XReportControlFormat::*pSetter)( const OUString& ) )
529 {
530 OUString aAttributeValue;
531 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
532 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
533 }
534
535
536 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
537 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
538 void (SAL_CALL report::XReportControlFormat::*pSetter)( const lang::Locale& ) )
539 {
540 lang::Locale aAttributeValue;
541 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
542 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
543 }
544}
545
546
547bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
548 const uno::Reference< awt::XWindow>& _rxParentWindow, uno::Sequence< beans::NamedValue >& _out_rNewValues )
549{
550 OSL_PRECOND( _rxReportControlFormat.is() && _rxParentWindow.is(), "openCharDialog: invalid parameters!" );
551 if ( !_rxReportControlFormat.is() || !_rxParentWindow.is() )
552 return false;
553
554 _out_rNewValues = uno::Sequence< beans::NamedValue >();
555
556
557 // UNO->ItemSet
558 static SfxItemInfo aItemInfos[] =
559 {
560 { 0, true },
561 { 0, true },
562 { 0, true },
563 { 0, true },
564 { 0, true },
565 { 0, true },
566 { 0, true },
567 { 0, true },
568 { 0, true },
569 { 0, true },
570 { 0, true },
571 { 0, true },
572 { 0, true },
573 { 0, true },
574 { 0, true },
575 { 0, true },
576 { 0, true },
577 { 0, true },
578 { 0, true },
579 { 0, true },
580
581 { SID_ATTR_CHAR_FONT, true },
582 { SID_ATTR_CHAR_FONTHEIGHT, true },
583 { SID_ATTR_CHAR_LANGUAGE, true },
584 { SID_ATTR_CHAR_POSTURE, true },
585 { SID_ATTR_CHAR_WEIGHT, true },
586 { SID_ATTR_CHAR_SHADOWED, true },
587 { SID_ATTR_CHAR_WORDLINEMODE, true },
588 { SID_ATTR_CHAR_CONTOUR, true },
589 { SID_ATTR_CHAR_STRIKEOUT, true },
590 { SID_ATTR_CHAR_UNDERLINE, true },
591 { SID_ATTR_CHAR_COLOR, true },
592 { SID_ATTR_CHAR_KERNING, true },
593 { SID_ATTR_CHAR_CASEMAP, true },
594 { SID_ATTR_CHAR_ESCAPEMENT, true },
595 { SID_ATTR_CHAR_FONTLIST, true },
596 { SID_ATTR_CHAR_AUTOKERN, true },
597 { SID_COLOR_TABLE, true },
598 { SID_ATTR_FLASH, true },
599 { SID_ATTR_CHAR_EMPHASISMARK, true },
600 { SID_ATTR_CHAR_TWO_LINES, true },
601 { SID_ATTR_CHAR_ROTATED, true },
602 { SID_ATTR_CHAR_SCALEWIDTH, true },
603 { SID_ATTR_CHAR_RELIEF, true },
604 { SID_ATTR_CHAR_HIDDEN, true },
605 { SID_ATTR_BRUSH, true },
606 { SID_ATTR_ALIGN_HOR_JUSTIFY, true },
607 { SID_ATTR_ALIGN_VER_JUSTIFY, true },
608
609 // Asian
610 { SID_ATTR_CHAR_CJK_FONT, true },
611 { SID_ATTR_CHAR_CJK_FONTHEIGHT, true },
612 { SID_ATTR_CHAR_CJK_LANGUAGE, true },
613 { SID_ATTR_CHAR_CJK_POSTURE, true },
614 { SID_ATTR_CHAR_CJK_WEIGHT, true },
615 // Complex
616 { SID_ATTR_CHAR_CTL_FONT, true },
617 { SID_ATTR_CHAR_CTL_FONTHEIGHT, true },
618 { SID_ATTR_CHAR_CTL_LANGUAGE, true },
619 { SID_ATTR_CHAR_CTL_POSTURE, true },
620 { SID_ATTR_CHAR_CTL_WEIGHT, true }
621 };
624 const ::Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
625 const ::Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
626 const XGradient aNullGrad(COL_BLACK, COL_WHITE);
627 const XHatch aNullHatch(aNullLineCol);
628 std::vector<SfxPoolItem*> pDefaults
629 {
630 new XFillStyleItem,
631 new XFillColorItem("", aNullFillCol),
632 new XFillGradientItem(aNullGrad),
633 new XFillHatchItem(aNullHatch),
638 new XFillBmpPosItem,
641 new XFillFloatTransparenceItem(aNullGrad, false),
642 new XSecondaryFillColorItem("", aNullFillCol),
650
656
662
665 new SvxCaseMapItem(SvxCaseMap::NotMapped,ITEMID_CASEMAP),
667 new SvxFontListItem(&aFontList,ITEMID_FONTLIST),
669 new SvxColorListItem(pColorList,ITEMID_COLOR_TABLE),
670 new SvxBlinkItem(false,ITEMID_BLINK),
671 new SvxEmphasisMarkItem(FontEmphasisMark::NONE,ITEMID_EMPHASISMARK),
672 new SvxTwoLinesItem(true,0,0,ITEMID_TWOLINES),
673 new SvxCharRotateItem(0_deg10,false,ITEMID_CHARROTATE),
675 new SvxCharReliefItem(FontRelief::NONE,ITEMID_CHARRELIEF),
680// Asian
686// Complex
692
693 };
694
695 OSL_ASSERT( pDefaults.size() == SAL_N_ELEMENTS(aItemInfos) );
696
697 static const WhichRangesContainer pRanges(svl::Items<
700 >);
701
702 rtl::Reference<SfxItemPool> pPool(new SfxItemPool("ReportCharProperties", XATTR_FILL_FIRST,ITEMID_WEIGHT_COMPLEX, aItemInfos, &pDefaults));
703 // not needed for font height pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
704 pPool->FreezeIdRanges(); // the same
705 bool bSuccess = false;
706 try
707 {
708 SfxItemSet aDescriptor( *pPool, pRanges );
709 lcl_CharPropertiesToItems( _rxReportControlFormat, aDescriptor );
710
711 { // want the dialog to be destroyed before our set
712 ORptPageDialog aDlg(Application::GetFrameWeld(_rxParentWindow), &aDescriptor, "CharDialog");
713 uno::Reference< report::XShape > xShape( _rxReportControlFormat, uno::UNO_QUERY );
714 if ( xShape.is() )
715 aDlg.RemoveTabPage("background");
716 bSuccess = aDlg.run() == RET_OK;
717 if ( bSuccess )
718 {
719 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat,WESTERN ),
720 lcl_getReportControlFont( _rxReportControlFormat,ASIAN ),
721 lcl_getReportControlFont( _rxReportControlFormat,COMPLEX ), *aDlg.GetOutputItemSet(), _out_rNewValues );
722 }
723 }
724 }
725 catch(uno::Exception&)
726 {
727 DBG_UNHANDLED_EXCEPTION("reportdesign");
728 }
729
730 pPool.clear();
731 for (SfxPoolItem* pDefault : pDefaults)
732 delete pDefault;
733
734 return bSuccess;
735}
736
737bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::Reference< awt::XWindow>& _rxParentWindow )
738{
739 OSL_PRECOND( _xShape.is() && _rxParentWindow.is(), "openAreaDialog: invalid parameters!" );
740 if ( !_xShape.is() || !_rxParentWindow.is() )
741 return false;
742
743 std::shared_ptr<rptui::OReportModel> pModel = ::reportdesign::OReportDefinition::getSdrModel(_xShape->getSection()->getReportDefinition());
744
745 weld::Window* pParent = Application::GetFrameWeld(_rxParentWindow);
746
747 bool bSuccess = false;
748 try
749 {
750 SfxItemPool& rItemPool = pModel->GetItemPool();
751 SfxItemSet aDescriptor( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
752 lcl_fillShapeToItems(_xShape, aDescriptor);
753
754 { // want the dialog to be destroyed before our set
757 pFact->CreateSvxAreaTabDialog(pParent, &aDescriptor, pModel.get(), true, false));
758 if ( RET_OK == pDialog->Execute() )
759 {
760 bSuccess = true;
761 lcl_fillItemsToShape(_xShape,*pDialog->GetOutputItemSet());
762 }
763 }
764 }
765 catch(uno::Exception&)
766 {
767 DBG_UNHANDLED_EXCEPTION("reportdesign");
768 }
769
770 return bSuccess;
771}
772
773
774void applyCharacterSettings( const uno::Reference< report::XReportControlFormat >& _rxReportControlFormat, const uno::Sequence< beans::NamedValue >& _rSettings )
775{
776 ::comphelper::NamedValueCollection aSettings( _rSettings );
777
778 try
779 {
780 awt::FontDescriptor aAwtFont;
781 if ( aSettings.get( "Font" ) >>= aAwtFont )
782 {
783 OUString sTemp = aAwtFont.Name;
784 aAwtFont.Name.clear(); // hack to
785 _rxReportControlFormat->setFontDescriptor( aAwtFont );
786 _rxReportControlFormat->setCharFontName( sTemp );
787 }
788 if ( aSettings.get( "FontAsian" ) >>= aAwtFont )
789 {
790 OUString sTemp = aAwtFont.Name;
791 aAwtFont.Name.clear(); // hack to
792 _rxReportControlFormat->setFontDescriptorAsian( aAwtFont );
793 _rxReportControlFormat->setCharFontNameAsian( sTemp );
794 }
795 if ( aSettings.get( "FontComplex" ) >>= aAwtFont )
796 {
797 OUString sTemp = aAwtFont.Name;
798 aAwtFont.Name.clear(); // hack to
799 _rxReportControlFormat->setFontDescriptorComplex( aAwtFont );
800 _rxReportControlFormat->setCharFontNameComplex( sTemp );
801 }
802
803 lcl_applyFontAttribute( aSettings, PROPERTY_CHARSHADOWED, _rxReportControlFormat, &report::XReportControlFormat::setCharShadowed );
804 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCONTOURED, _rxReportControlFormat, &report::XReportControlFormat::setCharContoured );
805 lcl_applyFontAttribute( aSettings, PROPERTY_CHARUNDERLINECOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharUnderlineColor );
806 lcl_applyFontAttribute( aSettings, PROPERTY_PARAADJUST, _rxReportControlFormat, &report::XReportControlFormat::setParaAdjust );
807 lcl_applyFontAttribute( aSettings, PROPERTY_VERTICALALIGN, _rxReportControlFormat, &report::XReportControlFormat::setVerticalAlign );
808 lcl_applyFontAttribute( aSettings, PROPERTY_CHARRELIEF, _rxReportControlFormat, &report::XReportControlFormat::setCharRelief );
809 lcl_applyFontAttribute( aSettings, PROPERTY_CHARHIDDEN, _rxReportControlFormat, &report::XReportControlFormat::setCharHidden );
810 lcl_applyFontAttribute( aSettings, PROPERTY_CHARAUTOKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharAutoKerning );
811 lcl_applyFontAttribute( aSettings, PROPERTY_CONTROLBACKGROUND, _rxReportControlFormat, &report::XReportControlFormat::setControlBackground );
812 lcl_applyFontAttribute( aSettings, PROPERTY_CHARFLASH, _rxReportControlFormat, &report::XReportControlFormat::setCharFlash );
813 lcl_applyFontAttribute( aSettings, PROPERTY_CHAREMPHASIS, _rxReportControlFormat, &report::XReportControlFormat::setCharEmphasis );
814 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEISON, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineIsOn );
815 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEPREFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombinePrefix );
816 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINESUFFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineSuffix );
817 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharColor );
818 lcl_applyFontAttribute( aSettings, PROPERTY_CHARKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharKerning );
819 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCASEMAP, _rxReportControlFormat, &report::XReportControlFormat::setCharCaseMap );
820 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALE, _rxReportControlFormat, &report::XReportControlFormat::setCharLocale );
821 lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapement );
822 lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENTHEIGHT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapementHeight );
823 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALEASIAN, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleAsian );
824 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALECOMPLEX, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleComplex );
825 }
826 catch( const uno::Exception& )
827 {
828 DBG_UNHANDLED_EXCEPTION("reportdesign");
829 }
830}
831
832void notifySystemWindow(vcl::Window const * _pWindow, vcl::Window* _pToRegister, const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& rMemFunc)
833{
834 OSL_ENSURE(_pWindow,"Window can not be null!");
835 SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : nullptr;
836 if ( pSystemWindow )
837 {
838 rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
839 }
840}
841
842SdrObject* isOver(const tools::Rectangle& _rRect, SdrPage const & _rPage, SdrView const & _rView, bool _bAllObjects, SdrObject const * _pIgnore, sal_Int16 _nIgnoreType)
843{
844 SdrObject* pOverlappedObj = nullptr;
845 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
846
847 while( !pOverlappedObj )
848 {
849 SdrObject* pObjIter = aIter.Next();
850 if( !pObjIter )
851 break;
852 if ( _pIgnore != pObjIter
853 && (_bAllObjects || !_rView.IsObjMarked(pObjIter))
854 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr))
855 {
856 if (_nIgnoreType == ISOVER_IGNORE_CUSTOMSHAPES && pObjIter->GetObjIdentifier() == SdrObjKind::CustomShape)
857 {
858 continue;
859 }
860
861 if (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr)
862 {
863 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
864 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
865 pOverlappedObj = pObjIter;
866 }
867 }
868 }
869 return pOverlappedObj;
870}
871
872static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, rtl::Reference<SdrUnoObj> _pIgnore[], int _nListLength)
873{
874 for(int i=0;i<_nListLength;i++)
875 {
876 SdrObject *pIgnore = _pIgnore[i].get();
877 if (pIgnore == _pObjToCheck)
878 {
879 return true;
880 }
881 }
882 return false;
883}
884
885SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, rtl::Reference<SdrUnoObj> _pIgnoreList[], int _nIgnoreListLength)
886{
887 SdrObject* pOverlappedObj = nullptr;
888 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
889
890 while( !pOverlappedObj )
891 {
892 SdrObject* pObjIter = aIter.Next();
893 if( !pObjIter )
894 break;
895 if (checkArrayForOccurrence(pObjIter, _pIgnoreList, _nIgnoreListLength))
896 {
897 continue;
898 }
899
900 if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter))
901 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr) )
902 {
903 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
904 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
905 pOverlappedObj = pObjIter;
906 }
907 }
908 return pOverlappedObj;
909}
910
911
912SdrObject* isOver(SdrObject const * _pObj,SdrPage const & _rPage,SdrView const & _rView)
913{
914 SdrObject* pOverlappedObj = nullptr;
915 if (dynamic_cast<OUnoObject const *>(_pObj) != nullptr || dynamic_cast<OOle2Obj const *>(_pObj) != nullptr) // this doesn't need to be done for shapes
916 {
917 tools::Rectangle aRect = _pObj->GetCurrentBoundRect();
918 pOverlappedObj = isOver(aRect,_rPage,_rView,false/*_bUnMarkedObjects*/,_pObj);
919 }
920 return pOverlappedObj;
921}
922
923
924uno::Sequence< OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet )
925{
926 uno::Sequence< OUString > aNames;
927
928 try
929 {
930 uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW );
931 uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() );
932 if ( xParams.is() )
933 {
934 sal_Int32 count( xParams->getCount() );
935 aNames.realloc( count );
936 auto pNames = aNames.getArray();
937
938 uno::Reference< beans::XPropertySet > xParam;
939 OUString sParamName;
940 for ( sal_Int32 i=0; i<count; ++i )
941 {
942 xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
943 OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName );
944 pNames[i] = sParamName;
945 }
946 }
947 }
948 catch( const uno::Exception& )
949 {
950 DBG_UNHANDLED_EXCEPTION("reportdesign");
951 }
952
953 return aNames;
954}
955
957{
958 if (_pControl)
959 {
960 uno::Reference< report::XReportComponent > xComponent( _pControl->getUnoShape(), uno::UNO_QUERY);
961 if (xComponent.is())
962 {
963 tools::Rectangle aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
964 aRect.setHeight(aRect.getOpenHeight() + 1);
965 aRect.setWidth(aRect.getOpenWidth() + 1);
966 return aRect;
967 }
968 }
969 return tools::Rectangle();
970}
971
972// check overlapping
973void correctOverlapping(SdrObject* _pControl,OReportSection const & _aReportSection,bool _bInsert)
974{
975 OSectionView& rSectionView = _aReportSection.getSectionView();
976 uno::Reference< report::XReportComponent> xComponent(_pControl->getUnoShape(),uno::UNO_QUERY);
977 tools::Rectangle aRect = getRectangleFromControl(_pControl);
978
979 bool bOverlapping = true;
980 while ( bOverlapping )
981 {
982 SdrObject* pOverlappedObj = isOver(aRect,*_aReportSection.getPage(),rSectionView,true, _pControl);
983 bOverlapping = pOverlappedObj != nullptr;
984 if ( bOverlapping )
985 {
986 const tools::Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
987 aRect.Move(0,aLogicRect.Top() + aLogicRect.getOpenHeight() - aRect.Top());
988 xComponent->setPositionY(aRect.Top());
989 }
990 }
991 if (_bInsert) // now insert objects
992 rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(), SdrInsertFlags::ADDMARK);
993}
994
995void setZoomFactor(const Fraction& _aZoom, vcl::Window& _rWindow)
996{
997 MapMode aMapMode( _rWindow.GetMapMode() );
998 aMapMode.SetScaleX(_aZoom);
999 aMapMode.SetScaleY(_aZoom);
1000 _rWindow.SetMapMode(aMapMode);
1001}
1002
1003bool openDialogFormula_nothrow( OUString& _in_out_rFormula
1004 , const css::uno::Reference< css::uno::XComponentContext >& _xContext
1005 , const uno::Reference< awt::XWindow>& _xInspectorWindow
1006 , const css::uno::Reference < css::beans::XPropertySet >& _xRowSet
1007 )
1008{
1009 OSL_PRECOND( _xInspectorWindow.is(), "openDialogFormula_nothrow: invalid parameters!" );
1010 if ( !_xInspectorWindow.is() )
1011 return false;
1012 bool bSuccess = false;
1013 ::dbtools::SQLExceptionInfo aErrorInfo;
1014 uno::Reference< awt::XWindow > xInspectorWindow;
1015 uno::Reference< lang::XMultiComponentFactory > xFactory;
1016 uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
1017 try
1018 {
1019 xFactory = _xContext->getServiceManager();
1020 xServiceFactory.set(xFactory,uno::UNO_QUERY);
1021
1022 uno::Reference< report::meta::XFunctionManager> xMgr(xFactory->createInstanceWithContext("org.libreoffice.report.pentaho.SOFunctionManager",_xContext),uno::UNO_QUERY);
1023 if ( xMgr.is() )
1024 {
1025 auto pFormulaManager = std::make_shared<FunctionManager>(xMgr);
1026 ReportFormula aFormula( _in_out_rFormula );
1027
1029 svl::SharedStringPool aStringPool(aCC);
1030
1031 FormulaDialog aDlg(
1032 Application::GetFrameWeld(_xInspectorWindow), xServiceFactory, pFormulaManager,
1033 aFormula.getUndecoratedContent(), _xRowSet, aStringPool);
1034
1035 bSuccess = aDlg.run() == RET_OK;
1036 if ( bSuccess )
1037 {
1038 OUString sFormula = aDlg.getCurrentFormula();
1039 if ( sFormula[0] == '=' )
1040 _in_out_rFormula = OUString::Concat("rpt:") + sFormula.subView(1);
1041 else
1042 _in_out_rFormula = "rpt:" + sFormula;
1043 }
1044 }
1045 }
1046 catch (const sdb::SQLContext& e) { aErrorInfo = e; }
1047 catch (const sdbc::SQLWarning& e) { aErrorInfo = e; }
1048 catch (const sdbc::SQLException& e) { aErrorInfo = e; }
1049 catch( const uno::Exception& )
1050 {
1051 TOOLS_WARN_EXCEPTION( "reportdesign", "GeometryHandler::impl_dialogFilter_nothrow" );
1052 }
1053
1054 if ( aErrorInfo.isValid() )
1055 ::dbtools::showError( aErrorInfo, xInspectorWindow, _xContext );
1056
1057 return bSuccess;
1058}
1059
1060} // namespace rptui
1061
1062
1063/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define ITEMID_POSTURE_ASIAN
Definition: UITools.cxx:160
#define ITEMID_FONTHEIGHT
Definition: UITools.cxx:128
#define ITEMID_WEIGHT
Definition: UITools.cxx:132
#define ITEMID_CHARSCALE_W
Definition: UITools.cxx:151
#define ITEMID_UNDERLINE
Definition: UITools.cxx:137
#define ITEMID_COLOR
Definition: UITools.cxx:139
#define ITEMID_FONTHEIGHT_COMPLEX
Definition: UITools.cxx:163
#define ITEMID_WEIGHT_ASIAN
Definition: UITools.cxx:161
#define ITEMID_KERNING
Definition: UITools.cxx:140
#define ITEMID_CHARHIDDEN
Definition: UITools.cxx:153
#define ITEMID_SHADOWED
Definition: UITools.cxx:133
#define ITEMID_BRUSH
Definition: UITools.cxx:154
#define ITEMID_BLINK
Definition: UITools.cxx:147
#define ITEMID_POSTURE
Definition: UITools.cxx:131
#define ITEMID_CASEMAP
Definition: UITools.cxx:141
#define ITEMID_COLOR_TABLE
Definition: UITools.cxx:146
#define ITEMID_CHARROTATE
Definition: UITools.cxx:150
#define ITEMID_LANGUAGE_ASIAN
Definition: UITools.cxx:159
#define ITEMID_FONTLIST
Definition: UITools.cxx:144
#define ITEMID_FONT_ASIAN
Definition: UITools.cxx:157
#define COMPLEX
Definition: UITools.cxx:170
#define ITEMID_TWOLINES
Definition: UITools.cxx:149
#define ITEMID_LANGUAGE_COMPLEX
Definition: UITools.cxx:164
#define ITEMID_HORJUSTIFY
Definition: UITools.cxx:155
#define ITEMID_LANGUAGE
Definition: UITools.cxx:129
#define ITEMID_VERJUSTIFY
Definition: UITools.cxx:156
#define ITEMID_WORDLINEMODE
Definition: UITools.cxx:134
#define ITEMID_CHARRELIEF
Definition: UITools.cxx:152
#define ITEMID_POSTURE_COMPLEX
Definition: UITools.cxx:165
#define ITEMID_CROSSEDOUT
Definition: UITools.cxx:136
#define WESTERN
Definition: UITools.cxx:168
#define ITEMID_WEIGHT_COMPLEX
Definition: UITools.cxx:166
#define ITEMID_ESCAPEMENT
Definition: UITools.cxx:143
#define ASIAN
Definition: UITools.cxx:169
#define ITEMID_FONT_COMPLEX
Definition: UITools.cxx:162
#define ITEMID_CONTOUR
Definition: UITools.cxx:135
#define ITEMID_FONTHEIGHT_ASIAN
Definition: UITools.cxx:158
#define ITEMID_EMPHASISMARK
Definition: UITools.cxx:148
#define ITEMID_FONT
Definition: UITools.cxx:127
#define ITEMID_AUTOKERN
Definition: UITools.cxx:145
const StyleSettings & GetStyleSettings() const
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
static OutputDevice * GetDefaultDevice()
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
void SetScaleY(const Fraction &rScaleY)
void SetScaleX(const Fraction &rScaleX)
const AllSettings & GetSettings() const
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
bool IsObjMarked(SdrObject const *pObj) const
SdrObject * Next()
static SdrItemPool & GetGlobalDrawObjectItemPool()
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
virtual const tools::Rectangle & GetCurrentBoundRect() const
virtual SdrObjKind GetObjIdentifier() const
virtual const tools::Rectangle & GetLastBoundRect() const
virtual const tools::Rectangle & GetLogicRect() const
SdrPageView * GetSdrPageView() const
sal_uInt16 GetLastWhich() const
sal_uInt16 GetFirstWhich() const
const o3tl::sorted_vector< const SfxItemPropertyMapEntry *, SfxItemPropertyMapCompare > & getPropertyEntries() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
std::unique_ptr< SfxPoolItem > CloneSetWhich(sal_uInt16 nNewWhich) const
virtual short run() override
const SfxItemSet * GetOutputItemSet() const
void RemoveTabPage(const OString &rName)
const vcl::Font & GetAppFont() const
virtual VclPtr< AbstractSvxAreaTabDialog > CreateSvxAreaTabDialog(weld::Window *pParent, const SfxItemSet *pAttr, SdrModel *pModel, bool bShadow, bool bSlideBackground)=0
static SvxAbstractDialogFactory * Create()
TaskPaneList * GetTaskPaneList()
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
static vcl::Font CreateFont(const css::awt::FontDescriptor &rDescr, const vcl::Font &rInitFont)
static XColorListRef CreateStdColorList()
const css::uno::Any & get(const OUString &_rValueName) const
static std::shared_ptr< rptui::OReportModel > getSdrModel(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition)
virtual OUString getCurrentFormula() const override
Definition: Formula.cxx:179
OReportPage * getPage() const
OSectionView & getSectionView() const
const OUString & getUndecoratedContent() const
gets the undecorated formula content
tools::Rectangle GetIntersection(const tools::Rectangle &rRect) const
constexpr tools::Long Top() const
tools::Long getOpenHeight() const
void setWidth(tools::Long n)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
void setHeight(tools::Long n)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
constexpr bool IsEmpty() const
void SetMapMode()
const MapMode & GetMapMode() const
SystemWindow * GetSystemWindow() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
inline ::Size VCLSize(const css::awt::Size &rAWTSize)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
OUString RptResId(TranslateId aId)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
SfxItemInfo const aItemInfos[]
OString sFormula
Reference< XSingleServiceFactory > xFactory
FontRelief
LINESTYLE_NONE
STRIKEOUT_NONE
ITALIC_NONE
FontEmphasisMark
WEIGHT_NORMAL
#define LANGUAGE_SYSTEM
#define LANGUAGE_GERMAN
#define SAL_N_ELEMENTS(arr)
const char * sName
int i
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
tools::Rectangle getRectangleFromControl(SdrObject *pControl)
returns a Rectangle of a given SdrObject
Definition: UITools.cxx:956
css::uno::Sequence< OUString > getParameterNames(const css::uno::Reference< css::sdbc::XRowSet > &_rxRowSet)
retrieves the names of the parameters of the command which the given RowSet is bound to
uno::Reference< style::XStyle > getUsedStyle(const uno::Reference< report::XReportDefinition > &_xReport)
Definition: RptObject.cxx:1176
::rtl::Reference< comphelper::OPropertyChangeMultiplexer > addStyleListener(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition,::comphelper::OPropertyChangeListener *_pListener)
add a listener for the properties size, left margin, right margin to the page style
void correctOverlapping(SdrObject *pControl, OReportSection const &_aReportSection, bool _bInsert=true)
ensures that no control overlaps the given one.
Definition: UITools.cxx:973
void notifySystemWindow(vcl::Window const *pWindow, vcl::Window *pToRegister, const ::comphelper::mem_fun1_t< TaskPaneList, vcl::Window * > &rMemFunc)
notifySystemWindow adds or remove the given window _pToRegister at the Systemwindow found when search...
Definition: UITools.cxx:832
bool openDialogFormula_nothrow(OUString &_in_out_rFormula, const css::uno::Reference< css::uno::XComponentContext > &_xContext, const css::uno::Reference< css::awt::XWindow > &_xWindow, const css::uno::Reference< css::beans::XPropertySet > &_xRowSet)
opens the formula dialog
bool openAreaDialog(const css::uno::Reference< css::report::XShape > &_xShape, const css::uno::Reference< css::awt::XWindow > &_xWindow)
opens the area dialog for shapes
const sal_Int16 ISOVER_IGNORE_CUSTOMSHAPES
Definition: UITools.hxx:131
SdrObject * isOver(const tools::Rectangle &_rRect, SdrPage const &_rPage, SdrView const &_rView, bool _bAllObjects=false, SdrObject const *_pIgnore=nullptr, sal_Int16 _nIgnoreType=0)
checks whether the given rectangle overlapps another OUnoObject object in that view.
Definition: UITools.cxx:842
void adjustSectionName(const css::uno::Reference< css::report::XGroup > &_xGroup, sal_Int32 _nPos)
set the name of the header and footer of the group by the expression appended by the localized name o...
void setZoomFactor(const Fraction &_aZoom, vcl::Window &_rWindow)
sets the map mode at the window
Definition: UITools.cxx:995
void applyCharacterSettings(const css::uno::Reference< css::report::XReportControlFormat > &_rxReportControlFormat, const css::uno::Sequence< css::beans::NamedValue > &_rSettings)
applies the character settings previously obtained via openCharDialog
static bool checkArrayForOccurrence(SdrObject const *_pObjToCheck, rtl::Reference< SdrUnoObj > _pIgnore[], int _nListLength)
Definition: UITools.cxx:872
bool openCharDialog(const css::uno::Reference< css::report::XReportControlFormat > &_xReportControlFormat, const css::uno::Reference< css::awt::XWindow > &_xWindow, css::uno::Sequence< css::beans::NamedValue > &_out_rNewValues)
opens the common character font dialog
static constexpr auto Items
VCL_DLLPUBLIC float ConvertFontWidth(FontWidth eWidth)
HashMap_OWString_Interface aMap
#define PROPERTY_CHARFLASH
Definition: strings.hxx:222
#define PROPERTY_CHARCOLOR
Definition: strings.hxx:85
#define PROPERTY_CHARUNDERLINECOLOR
Definition: strings.hxx:88
#define PROPERTY_CHARESCAPEMENTHEIGHT
Definition: strings.hxx:223
#define PROPERTY_CHARESCAPEMENT
Definition: strings.hxx:225
#define PROPERTY_PARAADJUST
Definition: strings.hxx:79
#define PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
#define PROPERTY_CHARCASEMAP
Definition: strings.hxx:226
#define PROPERTY_CHARLOCALE
Definition: strings.hxx:224
#define PROPERTY_CHARAUTOKERNING
Definition: strings.hxx:233
#define PROPERTY_CHARLOCALECOMPLEX
Definition: strings.hxx:179
#define PROPERTY_BACKCOLOR
Definition: strings.hxx:38
#define PROPERTY_CHARCOMBINEPREFIX
Definition: strings.hxx:228
#define PROPERTY_CHARLOCALEASIAN
Definition: strings.hxx:163
#define PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
#define PROPERTY_CONTROLBACKGROUND
Definition: strings.hxx:40
#define PROPERTY_CHARCOMBINEISON
Definition: strings.hxx:227
#define PROPERTY_CHARCOMBINESUFFIX
Definition: strings.hxx:229
#define PROPERTY_CHARHIDDEN
Definition: strings.hxx:230
#define PROPERTY_CHAREMPHASIS
Definition: strings.hxx:135
#define PROPERTY_PAPERSIZE
Definition: strings.hxx:62
#define PROPERTY_NAME
Definition: strings.hxx:36
#define PROPERTY_CHARSHADOWED
Definition: strings.hxx:231
#define PROPERTY_VERTICALALIGN
Definition: strings.hxx:86
#define PROPERTY_CHARCONTOURED
Definition: strings.hxx:232
#define PROPERTY_CHARRELIEF
Definition: strings.hxx:84
#define PROPERTY_CHARKERNING
Definition: strings.hxx:234
SvxCaseMap
signed char sal_Int8
Reference< XComponentContext > _xContext
RET_OK
#define COL_DEFAULT_SHAPE_FILLING
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
#define COL_DEFAULT_SHAPE_STROKE
constexpr TypedWhichId< XFillBackgroundItem > XATTR_FILLBACKGROUND(XATTR_FILL_FIRST+19)
constexpr TypedWhichId< XFillStyleItem > XATTR_FILLSTYLE(XATTR_FILL_FIRST)
sal_Int32 _nPos