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
168static_assert((ITEMID_WEIGHT_COMPLEX - XATTR_FILL_FIRST) == 56, "Item ids are not contiguous");
169
170#define WESTERN 0
171#define ASIAN 1
172#define COMPLEX 2
173
174namespace rptui
175{
176using namespace ::com::sun::star;
177using namespace formula;
178
179void adjustSectionName(const uno::Reference< report::XGroup >& _xGroup,sal_Int32 _nPos)
180{
181 OSL_ENSURE(_xGroup.is(),"Group is NULL -> GPF");
182 if ( _xGroup->getHeaderOn() && _xGroup->getHeader()->getName().isEmpty() )
183 {
184 OUString sName = RptResId(RID_STR_GROUPHEADER) + OUString::number(_nPos);
185 _xGroup->getHeader()->setName(sName);
186 }
187
188 if ( _xGroup->getFooterOn() && _xGroup->getFooter()->getName().isEmpty() )
189 {
190 OUString sName = RptResId(RID_STR_GROUPFOOTER) + OUString::number(_nPos);
191 _xGroup->getFooter()->setName(sName);
192 }
193}
194
195::rtl::Reference< comphelper::OPropertyChangeMultiplexer> addStyleListener(const uno::Reference< report::XReportDefinition >& _xReportDefinition,::comphelper::OPropertyChangeListener* _pListener)
196{
198 if ( _xReportDefinition.is() )
199 {
200 uno::Reference<beans::XPropertySet> xPageStyle(getUsedStyle(_xReportDefinition),uno::UNO_QUERY);
201 if ( xPageStyle.is() )
202 {
203 pRet = new comphelper::OPropertyChangeMultiplexer(_pListener,xPageStyle);
204 pRet->addProperty(PROPERTY_LEFTMARGIN);
205 pRet->addProperty(PROPERTY_RIGHTMARGIN);
206 pRet->addProperty(PROPERTY_PAPERSIZE);
207 pRet->addProperty(PROPERTY_BACKCOLOR);
208 }
209 }
210 return pRet;
211}
212
213
214namespace
215{
216
217 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat, awt::FontDescriptor& _out_rControlFont ,sal_uInt16 _nWichFont)
218 {
219 if ( !_rxReportControlFormat.is() )
220 throw uno::RuntimeException();
221
222 switch(_nWichFont)
223 {
224 case WESTERN:
225 _out_rControlFont = _rxReportControlFormat->getFontDescriptor();
226 break;
227 case ASIAN:
228 _out_rControlFont = _rxReportControlFormat->getFontDescriptorAsian();
229 break;
230 case COMPLEX:
231 _out_rControlFont = _rxReportControlFormat->getFontDescriptorComplex();
232 break;
233
234 }
235
237 return VCLUnoHelper::CreateFont( _out_rControlFont, aDefaultFont );
238 }
239
240
241 vcl::Font lcl_getReportControlFont( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,sal_uInt16 _nWhich )
242 {
243 awt::FontDescriptor aAwtFont;
244 return lcl_getReportControlFont( _rxReportControlFormat, aAwtFont, _nWhich );
245 }
246
247 vcl::Font lcl_setFont(const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
248 SfxItemSet& _rItemSet,sal_uInt16 _nWhich,sal_uInt16 _nFont, sal_uInt16 _nFontHeight,sal_uInt16 _nLanguage,sal_uInt16 _nPosture, sal_uInt16 _nWeight)
249 {
250 // fill it
251 awt::FontDescriptor aControlFont;
252 const vcl::Font aFont( lcl_getReportControlFont( _rxReportControlFormat, aControlFont,_nWhich ) );
253
254 SvxFontItem aFontItem(_nFont);
255 aFontItem.PutValue( uno::Any( aControlFont ), 0 );
256 _rItemSet.Put(aFontItem);
257
258 _rItemSet.Put(SvxFontHeightItem(o3tl::convert(aFont.GetFontHeight(), o3tl::Length::pt, o3tl::Length::twip), 100, _nFontHeight));
259 lang::Locale aLocale;
260 switch(_nWhich)
261 {
262 default:
263 aLocale = _rxReportControlFormat->getCharLocale();
264 break;
265 case ASIAN:
266 aLocale = _rxReportControlFormat->getCharLocaleAsian();
267 break;
268 case COMPLEX:
269 aLocale = _rxReportControlFormat->getCharLocaleComplex();
270 break;
271 }
272
273 _rItemSet.Put(SvxLanguageItem(LanguageTag(aLocale).makeFallback().getLanguageType(),_nLanguage));
274
275 _rItemSet.Put(SvxPostureItem(aFont.GetItalic(),_nPosture));
276 _rItemSet.Put(SvxWeightItem(aFont.GetWeight(),_nWeight));
277 return aFont;
278 }
279
280 void lcl_fillShapeToItems( const uno::Reference<report::XShape >& _xShape,SfxItemSet& _rItemSet )
281 {
282 uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
284 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
285 for (const auto pProp : rPropertyMap.getPropertyEntries())
286 {
287 if ( xInfo->hasPropertyByName(pProp->aName) )
288 {
289 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
290 if ( pItem )
291 {
292 ::std::unique_ptr<SfxPoolItem> pClone(pItem->CloneSetWhich(pProp->nWID));
293 pClone->PutValue(_xShape->getPropertyValue(pProp->aName), pProp->nMemberId);
294 _rItemSet.Put(std::move(pClone));
295 }
296 }
297 }
298 }
299
300 void lcl_fillItemsToShape( const uno::Reference<report::XShape >& _xShape,const SfxItemSet& _rItemSet )
301 {
302 const uno::Reference< beans::XPropertySetInfo> xInfo = _xShape->getPropertySetInfo();
304 const SfxItemPropertyMap& rPropertyMap = aMap.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool())->getPropertyMap();
305 for (const auto pProp : rPropertyMap.getPropertyEntries())
306 {
307 if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID) && xInfo->hasPropertyByName(pProp->aName) )
308 {
309 if ( ( pProp->nFlags & beans::PropertyAttribute::READONLY ) != beans::PropertyAttribute::READONLY )
310 {
311 const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
312 if ( pItem )
313 {
314 uno::Any aValue;
315 pItem->QueryValue(aValue, pProp->nMemberId);
316 try
317 {
318 _xShape->setPropertyValue(pProp->aName, aValue);
319 }
320 catch(uno::Exception&)
321 { // shapes have a bug so we ignore this one.
322 }
323 }
324 }
325 }
326 }
327 }
328
329 void lcl_CharPropertiesToItems( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
330 SfxItemSet& _rItemSet )
331 {
332 if ( !_rxReportControlFormat.is() )
333 throw lang::NullPointerException();
334
335 uno::Reference< beans::XPropertySet > xSet(_rxReportControlFormat,uno::UNO_QUERY_THROW);
336
337 // fill it
338 const vcl::Font aFont( lcl_setFont(_rxReportControlFormat, _rItemSet,WESTERN,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_LANGUAGE,ITEMID_POSTURE,ITEMID_WEIGHT ) );
339
340 _rItemSet.Put(SvxShadowedItem(_rxReportControlFormat->getCharShadowed(),ITEMID_SHADOWED));
341 _rItemSet.Put(SvxWordLineModeItem(aFont.IsWordLineMode(),ITEMID_WORDLINEMODE));
342 _rItemSet.Put(SvxContourItem(_rxReportControlFormat->getCharContoured(),ITEMID_CONTOUR));
343 _rItemSet.Put(SvxAutoKernItem(_rxReportControlFormat->getCharAutoKerning(),ITEMID_AUTOKERN));
344 _rItemSet.Put(SvxCrossedOutItem(aFont.GetStrikeout(),ITEMID_CROSSEDOUT));
345 _rItemSet.Put(SvxCaseMapItem(static_cast<SvxCaseMap>(_rxReportControlFormat->getCharCaseMap()),ITEMID_CASEMAP));
346
347 _rItemSet.Put(SvxEscapementItem(_rxReportControlFormat->getCharEscapement(),_rxReportControlFormat->getCharEscapementHeight(),ITEMID_ESCAPEMENT));
348 _rItemSet.Put(SvxBlinkItem(_rxReportControlFormat->getCharFlash(),ITEMID_BLINK));
349 _rItemSet.Put(SvxCharHiddenItem(_rxReportControlFormat->getCharHidden(),ITEMID_CHARHIDDEN));
350 _rItemSet.Put(SvxTwoLinesItem(_rxReportControlFormat->getCharCombineIsOn(),_rxReportControlFormat->getCharCombinePrefix().toChar(),_rxReportControlFormat->getCharCombineSuffix().toChar(),ITEMID_TWOLINES));
351 SvxUnderlineItem aUnderLineItem(aFont.GetUnderline(),ITEMID_UNDERLINE);
352 aUnderLineItem.SetColor(Color(ColorTransparency, _rxReportControlFormat->getCharUnderlineColor()));
353 _rItemSet.Put(aUnderLineItem);
354 _rItemSet.Put(SvxKerningItem(_rxReportControlFormat->getCharKerning(),ITEMID_KERNING));
355 _rItemSet.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark>(_rxReportControlFormat->getCharEmphasis()),ITEMID_EMPHASISMARK));
356 _rItemSet.Put(SvxCharReliefItem(static_cast<FontRelief>(_rxReportControlFormat->getCharRelief()),ITEMID_CHARRELIEF));
357 _rItemSet.Put(SvxColorItem(::Color(ColorTransparency, _rxReportControlFormat->getCharColor()),ITEMID_COLOR));
358 _rItemSet.Put(SvxCharRotateItem(Degree10(_rxReportControlFormat->getCharRotation()),false,ITEMID_CHARROTATE));
359 _rItemSet.Put(SvxCharScaleWidthItem(_rxReportControlFormat->getCharScaleWidth(),ITEMID_CHARSCALE_W));
360
361 SvxHorJustifyItem aHorJustifyItem(ITEMID_HORJUSTIFY);
362 aHorJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_PARAADJUST),MID_HORJUST_ADJUST);
363 _rItemSet.Put(aHorJustifyItem);
364 SvxVerJustifyItem aVerJustifyItem(ITEMID_VERJUSTIFY);
365 aVerJustifyItem.PutValue(xSet->getPropertyValue(PROPERTY_VERTICALALIGN),MID_HORJUST_ADJUST);
366 _rItemSet.Put(aVerJustifyItem);
367
368 uno::Reference< report::XShape> xShape(_rxReportControlFormat,uno::UNO_QUERY);
369 if ( !xShape.is() )
370 _rItemSet.Put(SvxBrushItem(::Color(ColorTransparency, _rxReportControlFormat->getControlBackground()),ITEMID_BRUSH));
371
374 }
375
376
377 void lcl_pushBack( uno::Sequence< beans::NamedValue >& _out_rProperties, const OUString& _sName, const uno::Any& _rValue )
378 {
379 sal_Int32 nLen( _out_rProperties.getLength() );
380 _out_rProperties.realloc( nLen + 1 );
381 _out_rProperties.getArray()[ nLen ] = beans::NamedValue( _sName, _rValue );
382 }
383
384
385 void lcl_initAwtFont( const vcl::Font& _rOriginalFont, const SfxItemSet& _rItemSet, awt::FontDescriptor& _out_rAwtFont,
388 {
389 vcl::Font aNewFont( _rOriginalFont );
390 if ( const SvxFontItem* pFontItem = _rItemSet.GetItemIfSet( _nFont) )
391 {
392 aNewFont.SetFamilyName(pFontItem->GetFamilyName());
393 aNewFont.SetStyleName(pFontItem->GetStyleName());
394 aNewFont.SetFamily(pFontItem->GetFamily());
395 aNewFont.SetPitch(pFontItem->GetPitch());
396 aNewFont.SetCharSet(pFontItem->GetCharSet());
397 }
398 if ( const SvxFontHeightItem* pFontItem = _rItemSet.GetItemIfSet( _nFontHeight ) )
399 {
400 aNewFont.SetFontHeight(o3tl::convert(pFontItem->GetHeight(), o3tl::Length::twip, o3tl::Length::pt));
401 }
402 if ( const SvxPostureItem* pPostureItem = _rItemSet.GetItemIfSet( _nPosture) )
403 {
404 aNewFont.SetItalic(pPostureItem->GetPosture());
405 }
406 if ( const SvxWeightItem* pWeightItem = _rItemSet.GetItemIfSet( _nWeight ) )
407 {
408 aNewFont.SetWeight(pWeightItem->GetWeight());
409 }
410 if ( const SvxWordLineModeItem* pWordLineItem = _rItemSet.GetItemIfSet( ITEMID_WORDLINEMODE ) )
411 {
412 aNewFont.SetWordLineMode(pWordLineItem->GetValue());
413 }
414 if ( const SvxCrossedOutItem* pCrossedOutItem = _rItemSet.GetItemIfSet( ITEMID_CROSSEDOUT ) )
415 {
416 aNewFont.SetStrikeout(pCrossedOutItem->GetStrikeout());
417 }
418 if ( const SvxCharRotateItem* pRotateItem = _rItemSet.GetItemIfSet( ITEMID_CHARROTATE ) )
419 {
420 aNewFont.SetOrientation(pRotateItem->GetValue());
421 }
422 if ( const SvxCharScaleWidthItem* pCharItem = _rItemSet.GetItemIfSet( ITEMID_CHARSCALE_W ) )
423 {
424 aNewFont.SetWidthType(vcl::unohelper::ConvertFontWidth(pCharItem->GetValue()));
425 }
426 if ( const SvxUnderlineItem* pUnderlineItem = _rItemSet.GetItemIfSet( ITEMID_UNDERLINE ) )
427 {
428 aNewFont.SetUnderline(pUnderlineItem->GetLineStyle());
429 }
430 if ( const SvxColorItem* pColorItem = _rItemSet.GetItemIfSet( ITEMID_COLOR ) )
431 {
432 aNewFont.SetColor(pColorItem->GetValue());
433 }
434
435 _out_rAwtFont = VCLUnoHelper::CreateFontDescriptor( aNewFont );
436 }
437
438
439 void lcl_itemsToCharProperties( const vcl::Font& _rOriginalControlFont,const vcl::Font& _rOriginalControlFontAsian,const vcl::Font& _rOriginalControlFontComplex, const SfxItemSet& _rItemSet, uno::Sequence< beans::NamedValue >& _out_rProperties )
440 {
441 // create an AWT font
442 awt::FontDescriptor aAwtFont;
443 lcl_initAwtFont( _rOriginalControlFont, _rItemSet, aAwtFont,ITEMID_FONT,ITEMID_FONTHEIGHT,ITEMID_POSTURE, ITEMID_WEIGHT);
444 lcl_pushBack( _out_rProperties, "Font", uno::Any( aAwtFont ) );
445 lcl_initAwtFont( _rOriginalControlFontAsian, _rItemSet, aAwtFont,ITEMID_FONT_ASIAN,ITEMID_FONTHEIGHT_ASIAN,ITEMID_POSTURE_ASIAN, ITEMID_WEIGHT_ASIAN);
446 lcl_pushBack( _out_rProperties, "FontAsian", uno::Any( aAwtFont ) );
447 lcl_initAwtFont( _rOriginalControlFontComplex, _rItemSet, aAwtFont,ITEMID_FONT_COMPLEX,ITEMID_FONTHEIGHT_COMPLEX,ITEMID_POSTURE_COMPLEX, ITEMID_WEIGHT_COMPLEX);
448 lcl_pushBack( _out_rProperties, "FontComplex", uno::Any( aAwtFont ) );
449
450 // properties which cannot be represented in an AWT font need to be preserved directly
451 if ( const SvxShadowedItem* pShadowedItem = _rItemSet.GetItemIfSet( ITEMID_SHADOWED) )
452 lcl_pushBack( _out_rProperties, PROPERTY_CHARSHADOWED, uno::Any( pShadowedItem->GetValue() ) );
453 if ( const SvxContourItem* pContourItem = _rItemSet.GetItemIfSet( ITEMID_CONTOUR ) )
454 lcl_pushBack( _out_rProperties, PROPERTY_CHARCONTOURED, uno::Any( pContourItem->GetValue() ) );
455 if ( const SvxUnderlineItem* pUnderlineItem = _rItemSet.GetItemIfSet( ITEMID_UNDERLINE ) )
456 lcl_pushBack( _out_rProperties, PROPERTY_CHARUNDERLINECOLOR, uno::Any( pUnderlineItem->GetColor() ) );
457 if ( const SvxHorJustifyItem* pJustifyItem = _rItemSet.GetItemIfSet( ITEMID_HORJUSTIFY ) )
458 {
459 uno::Any aValue;
460 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
461 lcl_pushBack( _out_rProperties, PROPERTY_PARAADJUST, aValue );
462 }
463 if ( const SvxVerJustifyItem* pJustifyItem = _rItemSet.GetItemIfSet( ITEMID_VERJUSTIFY ) )
464 {
465 uno::Any aValue;
466 pJustifyItem->QueryValue(aValue,MID_HORJUST_ADJUST);
467 lcl_pushBack( _out_rProperties, PROPERTY_VERTICALALIGN, aValue );
468 }
469 if ( const SvxCharReliefItem* pReliefItem = _rItemSet.GetItemIfSet( ITEMID_CHARRELIEF ) )
470 lcl_pushBack( _out_rProperties, PROPERTY_CHARRELIEF, uno::Any( static_cast< sal_Int16 >( pReliefItem->GetEnumValue() ) ) );
471 if ( const SvxCharHiddenItem* pHiddenItem = _rItemSet.GetItemIfSet( ITEMID_CHARHIDDEN ) )
472 lcl_pushBack( _out_rProperties, PROPERTY_CHARHIDDEN, uno::Any( pHiddenItem->GetValue() ) );
473 if ( const SvxAutoKernItem* pKernItem = _rItemSet.GetItemIfSet( ITEMID_AUTOKERN ) )
474 lcl_pushBack( _out_rProperties, PROPERTY_CHARAUTOKERNING, uno::Any( pKernItem->GetValue() ) );
475 if ( const SvxBrushItem* pBrushItem = _rItemSet.GetItemIfSet( ITEMID_BRUSH ) )
476 lcl_pushBack( _out_rProperties, PROPERTY_CONTROLBACKGROUND, uno::Any( pBrushItem->GetColor() ) );
477 if ( const SvxBlinkItem* pBlinkItem = _rItemSet.GetItemIfSet( ITEMID_BLINK ) )
478 lcl_pushBack( _out_rProperties, PROPERTY_CHARFLASH, uno::Any( pBlinkItem->GetValue() ) );
479 if ( const SvxEmphasisMarkItem* pMarkItem = _rItemSet.GetItemIfSet( ITEMID_EMPHASISMARK ) )
480 lcl_pushBack( _out_rProperties, PROPERTY_CHAREMPHASIS, uno::Any( static_cast< sal_Int16 >( pMarkItem->GetEmphasisMark() ) ) );
481 if ( const SvxTwoLinesItem* pLinesItem = _rItemSet.GetItemIfSet( ITEMID_TWOLINES ) )
482 {
483 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEISON, uno::Any( pLinesItem->GetValue() ) );
484 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINEPREFIX, uno::Any( OUString( pLinesItem->GetStartBracket() ) ) );
485 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOMBINESUFFIX, uno::Any( OUString( pLinesItem->GetEndBracket() ) ) );
486 }
487 if ( const SvxColorItem* pColorItem = _rItemSet.GetItemIfSet( ITEMID_COLOR ) )
488 lcl_pushBack( _out_rProperties, PROPERTY_CHARCOLOR, uno::Any( pColorItem->GetValue() ) );
489 if ( const SvxKerningItem* pKernItem = _rItemSet.GetItemIfSet( ITEMID_KERNING ) )
490 lcl_pushBack( _out_rProperties, PROPERTY_CHARKERNING, uno::Any( pKernItem->GetValue() ) );
491 if ( const SvxCaseMapItem* pCaseMapItem = _rItemSet.GetItemIfSet( ITEMID_CASEMAP ) )
492 lcl_pushBack( _out_rProperties, PROPERTY_CHARCASEMAP, uno::Any( pCaseMapItem->GetEnumValue() ) );
493 struct Items {
495 OUString sPropertyName;
496 };
497 const Items pItems[] = { {ITEMID_LANGUAGE,OUString(PROPERTY_CHARLOCALE)}
500 };
501 for(const auto & k : pItems)
502 {
503 if ( const SvxLanguageItem* pLanguageItem = _rItemSet.GetItemIfSet( k.nWhich ) )
504 {
505 lang::Locale aCharLocale( LanguageTag( pLanguageItem->GetLanguage()).getLocale());
506 lcl_pushBack( _out_rProperties, k.sPropertyName, uno::Any( aCharLocale ) );
507 }
508 }
509 if ( const SvxEscapementItem* pEscapementItem = _rItemSet.GetItemIfSet( ITEMID_ESCAPEMENT ) )
510 {
511 lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENT, uno::Any( pEscapementItem->GetEsc() ) );
512 lcl_pushBack( _out_rProperties, PROPERTY_CHARESCAPEMENTHEIGHT, uno::Any(static_cast<sal_Int8>(pEscapementItem->GetProportionalHeight())) );
513 }
514 }
515
516
517 template< class ATTRIBUTE_TYPE >
518 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
519 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
520 void (SAL_CALL report::XReportControlFormat::*pSetter)( ATTRIBUTE_TYPE ) )
521 {
522 ATTRIBUTE_TYPE aAttributeValue = ATTRIBUTE_TYPE();
523 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
524 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
525 }
526
527
528 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
529 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
530 void (SAL_CALL report::XReportControlFormat::*pSetter)( const OUString& ) )
531 {
532 OUString aAttributeValue;
533 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
534 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
535 }
536
537
538 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection& _rAttrValues, const OUString& _pAttributeName,
539 const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
540 void (SAL_CALL report::XReportControlFormat::*pSetter)( const lang::Locale& ) )
541 {
542 lang::Locale aAttributeValue;
543 if ( _rAttrValues.get_ensureType( _pAttributeName, aAttributeValue ) )
544 (_rxReportControlFormat.get()->*pSetter)( aAttributeValue );
545 }
546}
547
548
549bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxReportControlFormat,
550 const uno::Reference< awt::XWindow>& _rxParentWindow, uno::Sequence< beans::NamedValue >& _out_rNewValues )
551{
552 OSL_PRECOND( _rxReportControlFormat.is() && _rxParentWindow.is(), "openCharDialog: invalid parameters!" );
553 if ( !_rxReportControlFormat.is() || !_rxParentWindow.is() )
554 return false;
555
556 _out_rNewValues = uno::Sequence< beans::NamedValue >();
557
558
559 // UNO->ItemSet
560 static SfxItemInfo aItemInfos[] =
561 {
562 { 0, true }, // XATTR_FILLSTYLE
563 { 0, true }, // XATTR_FILLCOLOR
564 { 0, true }, // XATTR_FILLGRADIENT
565 { 0, true }, // XATTR_FILLHATCH
566 { 0, true }, // XATTR_FILLBITMAP
567 { 0, true }, // XATTR_FILLTRANSPARENCE
568 { 0, true }, // XATTR_GRADIENTSTEPCOUNT
569 { 0, true }, // XATTR_FILLBMP_TILE
570 { 0, true }, // XATTR_FILLBMP_POS
571 { 0, true }, // XATTR_FILLBMP_SIZEX
572 { 0, true }, // XATTR_FILLBMP_SIZEY
573 { 0, true }, // XATTR_FILLFLOATTRANSPARENCE
574 { 0, true }, // XATTR_SECONDARYFILLCOLOR
575 { 0, true }, // XATTR_FILLBMP_SIZELOG
576 { 0, true }, // XATTR_FILLBMP_TILEOFFSETX
577 { 0, true }, // XATTR_FILLBMP_TILEOFFSETY
578 { 0, true }, // XATTR_FILLBMP_STRETCH
579 { 0, true }, // XATTR_FILLBMP_POSOFFSETX
580 { 0, true }, // XATTR_FILLBMP_POSOFFSETY
581 { 0, true }, // XATTR_FILLBACKGROUND
582
583 { SID_ATTR_CHAR_FONT, true },
584 { SID_ATTR_CHAR_FONTHEIGHT, true },
585 { SID_ATTR_CHAR_LANGUAGE, true },
586 { SID_ATTR_CHAR_POSTURE, true },
587 { SID_ATTR_CHAR_WEIGHT, true },
588 { SID_ATTR_CHAR_SHADOWED, true },
589 { SID_ATTR_CHAR_WORDLINEMODE, true },
590 { SID_ATTR_CHAR_CONTOUR, true },
591 { SID_ATTR_CHAR_STRIKEOUT, true },
592 { SID_ATTR_CHAR_UNDERLINE, true },
593 { SID_ATTR_CHAR_COLOR, true },
594 { SID_ATTR_CHAR_KERNING, true },
595 { SID_ATTR_CHAR_CASEMAP, true },
596 { SID_ATTR_CHAR_ESCAPEMENT, true },
597 { SID_ATTR_CHAR_FONTLIST, true },
598 { SID_ATTR_CHAR_AUTOKERN, true },
599 { SID_COLOR_TABLE, true },
600 { SID_ATTR_FLASH, true },
601 { SID_ATTR_CHAR_EMPHASISMARK, true },
602 { SID_ATTR_CHAR_TWO_LINES, true },
603 { SID_ATTR_CHAR_ROTATED, true },
604 { SID_ATTR_CHAR_SCALEWIDTH, true },
605 { SID_ATTR_CHAR_RELIEF, true },
606 { SID_ATTR_CHAR_HIDDEN, true },
607 { SID_ATTR_BRUSH, true },
608 { SID_ATTR_ALIGN_HOR_JUSTIFY, true },
609 { SID_ATTR_ALIGN_VER_JUSTIFY, true },
610
611 // Asian
612 { SID_ATTR_CHAR_CJK_FONT, true },
613 { SID_ATTR_CHAR_CJK_FONTHEIGHT, true },
614 { SID_ATTR_CHAR_CJK_LANGUAGE, true },
615 { SID_ATTR_CHAR_CJK_POSTURE, true },
616 { SID_ATTR_CHAR_CJK_WEIGHT, true },
617 // Complex
618 { SID_ATTR_CHAR_CTL_FONT, true },
619 { SID_ATTR_CHAR_CTL_FONTHEIGHT, true },
620 { SID_ATTR_CHAR_CTL_LANGUAGE, true },
621 { SID_ATTR_CHAR_CTL_POSTURE, true },
622 { SID_ATTR_CHAR_CTL_WEIGHT, true }
623 };
626 const ::Color aNullLineCol(COL_DEFAULT_SHAPE_STROKE); // #i121448# Use defined default color
627 const ::Color aNullFillCol(COL_DEFAULT_SHAPE_FILLING); // #i121448# Use defined default color
628 const XGradient aNullGrad(COL_BLACK, COL_WHITE);
629 const XHatch aNullHatch(aNullLineCol);
630 std::vector<SfxPoolItem*> pDefaults
631 {
632 new XFillStyleItem,
633 new XFillColorItem("", aNullFillCol),
634 new XFillGradientItem(aNullGrad),
635 new XFillHatchItem(aNullHatch),
640 new XFillBmpPosItem,
643 new XFillFloatTransparenceItem(aNullGrad, false),
644 new XSecondaryFillColorItem("", aNullFillCol),
652
658
664
667 new SvxCaseMapItem(SvxCaseMap::NotMapped,ITEMID_CASEMAP),
669 new SvxFontListItem(&aFontList,ITEMID_FONTLIST),
671 new SvxColorListItem(pColorList,ITEMID_COLOR_TABLE),
672 new SvxBlinkItem(false,ITEMID_BLINK),
673 new SvxEmphasisMarkItem(FontEmphasisMark::NONE,ITEMID_EMPHASISMARK),
674 new SvxTwoLinesItem(true,0,0,ITEMID_TWOLINES),
675 new SvxCharRotateItem(0_deg10,false,ITEMID_CHARROTATE),
677 new SvxCharReliefItem(FontRelief::NONE,ITEMID_CHARRELIEF),
682// Asian
688// Complex
694
695 };
696
697 OSL_ASSERT( pDefaults.size() == SAL_N_ELEMENTS(aItemInfos) );
698
699 static const WhichRangesContainer pRanges(svl::Items<
702 >);
703
704 rtl::Reference<SfxItemPool> pPool(new SfxItemPool("ReportCharProperties", XATTR_FILL_FIRST,ITEMID_WEIGHT_COMPLEX, aItemInfos, &pDefaults));
705 // not needed for font height pPool->SetDefaultMetric( MapUnit::Map100thMM ); // ripped, don't understand why
706 pPool->FreezeIdRanges(); // the same
707 bool bSuccess = false;
708 try
709 {
710 SfxItemSet aDescriptor( *pPool, pRanges );
711 lcl_CharPropertiesToItems( _rxReportControlFormat, aDescriptor );
712
713 { // want the dialog to be destroyed before our set
714 ORptPageDialog aDlg(Application::GetFrameWeld(_rxParentWindow), &aDescriptor, "CharDialog");
715 uno::Reference< report::XShape > xShape( _rxReportControlFormat, uno::UNO_QUERY );
716 if ( xShape.is() )
717 aDlg.RemoveTabPage("background");
718 bSuccess = aDlg.run() == RET_OK;
719 if ( bSuccess )
720 {
721 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat,WESTERN ),
722 lcl_getReportControlFont( _rxReportControlFormat,ASIAN ),
723 lcl_getReportControlFont( _rxReportControlFormat,COMPLEX ), *aDlg.GetOutputItemSet(), _out_rNewValues );
724 }
725 }
726 }
727 catch(uno::Exception&)
728 {
729 DBG_UNHANDLED_EXCEPTION("reportdesign");
730 }
731
732 pPool.clear();
733 for (SfxPoolItem* pDefault : pDefaults)
734 delete pDefault;
735
736 return bSuccess;
737}
738
739bool openAreaDialog( const uno::Reference<report::XShape >& _xShape,const uno::Reference< awt::XWindow>& _rxParentWindow )
740{
741 OSL_PRECOND( _xShape.is() && _rxParentWindow.is(), "openAreaDialog: invalid parameters!" );
742 if ( !_xShape.is() || !_rxParentWindow.is() )
743 return false;
744
745 std::shared_ptr<rptui::OReportModel> pModel = ::reportdesign::OReportDefinition::getSdrModel(_xShape->getSection()->getReportDefinition());
746
747 weld::Window* pParent = Application::GetFrameWeld(_rxParentWindow);
748
749 bool bSuccess = false;
750 try
751 {
752 SfxItemPool& rItemPool = pModel->GetItemPool();
753 SfxItemSet aDescriptor( rItemPool, rItemPool.GetFirstWhich(), rItemPool.GetLastWhich() );
754 lcl_fillShapeToItems(_xShape, aDescriptor);
755
756 { // want the dialog to be destroyed before our set
759 pFact->CreateSvxAreaTabDialog(pParent, &aDescriptor, pModel.get(), true, false));
760 if ( RET_OK == pDialog->Execute() )
761 {
762 bSuccess = true;
763 lcl_fillItemsToShape(_xShape,*pDialog->GetOutputItemSet());
764 }
765 }
766 }
767 catch(uno::Exception&)
768 {
769 DBG_UNHANDLED_EXCEPTION("reportdesign");
770 }
771
772 return bSuccess;
773}
774
775
776void applyCharacterSettings( const uno::Reference< report::XReportControlFormat >& _rxReportControlFormat, const uno::Sequence< beans::NamedValue >& _rSettings )
777{
778 ::comphelper::NamedValueCollection aSettings( _rSettings );
779
780 try
781 {
782 awt::FontDescriptor aAwtFont;
783 if ( aSettings.get( "Font" ) >>= aAwtFont )
784 {
785 OUString sTemp = aAwtFont.Name;
786 aAwtFont.Name.clear(); // hack to
787 _rxReportControlFormat->setFontDescriptor( aAwtFont );
788 _rxReportControlFormat->setCharFontName( sTemp );
789 }
790 if ( aSettings.get( "FontAsian" ) >>= aAwtFont )
791 {
792 OUString sTemp = aAwtFont.Name;
793 aAwtFont.Name.clear(); // hack to
794 _rxReportControlFormat->setFontDescriptorAsian( aAwtFont );
795 _rxReportControlFormat->setCharFontNameAsian( sTemp );
796 }
797 if ( aSettings.get( "FontComplex" ) >>= aAwtFont )
798 {
799 OUString sTemp = aAwtFont.Name;
800 aAwtFont.Name.clear(); // hack to
801 _rxReportControlFormat->setFontDescriptorComplex( aAwtFont );
802 _rxReportControlFormat->setCharFontNameComplex( sTemp );
803 }
804
805 lcl_applyFontAttribute( aSettings, PROPERTY_CHARSHADOWED, _rxReportControlFormat, &report::XReportControlFormat::setCharShadowed );
806 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCONTOURED, _rxReportControlFormat, &report::XReportControlFormat::setCharContoured );
807 lcl_applyFontAttribute( aSettings, PROPERTY_CHARUNDERLINECOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharUnderlineColor );
808 lcl_applyFontAttribute( aSettings, PROPERTY_PARAADJUST, _rxReportControlFormat, &report::XReportControlFormat::setParaAdjust );
809 lcl_applyFontAttribute( aSettings, PROPERTY_VERTICALALIGN, _rxReportControlFormat, &report::XReportControlFormat::setVerticalAlign );
810 lcl_applyFontAttribute( aSettings, PROPERTY_CHARRELIEF, _rxReportControlFormat, &report::XReportControlFormat::setCharRelief );
811 lcl_applyFontAttribute( aSettings, PROPERTY_CHARHIDDEN, _rxReportControlFormat, &report::XReportControlFormat::setCharHidden );
812 lcl_applyFontAttribute( aSettings, PROPERTY_CHARAUTOKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharAutoKerning );
813 lcl_applyFontAttribute( aSettings, PROPERTY_CONTROLBACKGROUND, _rxReportControlFormat, &report::XReportControlFormat::setControlBackground );
814 lcl_applyFontAttribute( aSettings, PROPERTY_CHARFLASH, _rxReportControlFormat, &report::XReportControlFormat::setCharFlash );
815 lcl_applyFontAttribute( aSettings, PROPERTY_CHAREMPHASIS, _rxReportControlFormat, &report::XReportControlFormat::setCharEmphasis );
816 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEISON, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineIsOn );
817 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINEPREFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombinePrefix );
818 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOMBINESUFFIX, _rxReportControlFormat, &report::XReportControlFormat::setCharCombineSuffix );
819 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCOLOR, _rxReportControlFormat, &report::XReportControlFormat::setCharColor );
820 lcl_applyFontAttribute( aSettings, PROPERTY_CHARKERNING, _rxReportControlFormat, &report::XReportControlFormat::setCharKerning );
821 lcl_applyFontAttribute( aSettings, PROPERTY_CHARCASEMAP, _rxReportControlFormat, &report::XReportControlFormat::setCharCaseMap );
822 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALE, _rxReportControlFormat, &report::XReportControlFormat::setCharLocale );
823 lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapement );
824 lcl_applyFontAttribute( aSettings, PROPERTY_CHARESCAPEMENTHEIGHT, _rxReportControlFormat, &report::XReportControlFormat::setCharEscapementHeight );
825 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALEASIAN, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleAsian );
826 lcl_applyFontAttribute( aSettings, PROPERTY_CHARLOCALECOMPLEX, _rxReportControlFormat, &report::XReportControlFormat::setCharLocaleComplex );
827 }
828 catch( const uno::Exception& )
829 {
830 DBG_UNHANDLED_EXCEPTION("reportdesign");
831 }
832}
833
834void notifySystemWindow(vcl::Window const * _pWindow, vcl::Window* _pToRegister, const ::comphelper::mem_fun1_t<TaskPaneList,vcl::Window*>& rMemFunc)
835{
836 OSL_ENSURE(_pWindow,"Window can not be null!");
837 SystemWindow* pSystemWindow = _pWindow ? _pWindow->GetSystemWindow() : nullptr;
838 if ( pSystemWindow )
839 {
840 rMemFunc( pSystemWindow->GetTaskPaneList(), _pToRegister );
841 }
842}
843
844SdrObject* isOver(const tools::Rectangle& _rRect, SdrPage const & _rPage, SdrView const & _rView, bool _bAllObjects, SdrObject const * _pIgnore, sal_Int16 _nIgnoreType)
845{
846 SdrObject* pOverlappedObj = nullptr;
847 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
848
849 while( !pOverlappedObj )
850 {
851 SdrObject* pObjIter = aIter.Next();
852 if( !pObjIter )
853 break;
854 if ( _pIgnore != pObjIter
855 && (_bAllObjects || !_rView.IsObjMarked(pObjIter))
856 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr))
857 {
858 if (_nIgnoreType == ISOVER_IGNORE_CUSTOMSHAPES && pObjIter->GetObjIdentifier() == SdrObjKind::CustomShape)
859 {
860 continue;
861 }
862
863 if (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr)
864 {
865 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
866 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
867 pOverlappedObj = pObjIter;
868 }
869 }
870 }
871 return pOverlappedObj;
872}
873
874static bool checkArrayForOccurrence(SdrObject const * _pObjToCheck, rtl::Reference<SdrUnoObj> _pIgnore[], int _nListLength)
875{
876 for(int i=0;i<_nListLength;i++)
877 {
878 SdrObject *pIgnore = _pIgnore[i].get();
879 if (pIgnore == _pObjToCheck)
880 {
881 return true;
882 }
883 }
884 return false;
885}
886
887SdrObject* isOver(const tools::Rectangle& _rRect,SdrPage const & _rPage,SdrView const & _rView,bool _bAllObjects, rtl::Reference<SdrUnoObj> _pIgnoreList[], int _nIgnoreListLength)
888{
889 SdrObject* pOverlappedObj = nullptr;
890 SdrObjListIter aIter(&_rPage,SdrIterMode::DeepNoGroups);
891
892 while( !pOverlappedObj )
893 {
894 SdrObject* pObjIter = aIter.Next();
895 if( !pObjIter )
896 break;
897 if (checkArrayForOccurrence(pObjIter, _pIgnoreList, _nIgnoreListLength))
898 {
899 continue;
900 }
901
902 if ( (_bAllObjects || !_rView.IsObjMarked(pObjIter))
903 && (dynamic_cast<OUnoObject*>(pObjIter) != nullptr || dynamic_cast<OOle2Obj*>(pObjIter) != nullptr) )
904 {
905 tools::Rectangle aRect = _rRect.GetIntersection(pObjIter->GetLastBoundRect());
906 if ( !aRect.IsEmpty() && (aRect.Left() != aRect.Right() && aRect.Top() != aRect.Bottom() ) )
907 pOverlappedObj = pObjIter;
908 }
909 }
910 return pOverlappedObj;
911}
912
913
914SdrObject* isOver(SdrObject const * _pObj,SdrPage const & _rPage,SdrView const & _rView)
915{
916 SdrObject* pOverlappedObj = nullptr;
917 if (dynamic_cast<OUnoObject const *>(_pObj) != nullptr || dynamic_cast<OOle2Obj const *>(_pObj) != nullptr) // this doesn't need to be done for shapes
918 {
919 tools::Rectangle aRect = _pObj->GetCurrentBoundRect();
920 pOverlappedObj = isOver(aRect,_rPage,_rView,false/*_bUnMarkedObjects*/,_pObj);
921 }
922 return pOverlappedObj;
923}
924
925
926uno::Sequence< OUString > getParameterNames( const uno::Reference< sdbc::XRowSet >& _rxRowSet )
927{
928 uno::Sequence< OUString > aNames;
929
930 try
931 {
932 uno::Reference< sdb::XParametersSupplier > xSuppParams( _rxRowSet, uno::UNO_QUERY_THROW );
933 uno::Reference< container::XIndexAccess > xParams( xSuppParams->getParameters() );
934 if ( xParams.is() )
935 {
936 sal_Int32 count( xParams->getCount() );
937 aNames.realloc( count );
938 auto pNames = aNames.getArray();
939
940 uno::Reference< beans::XPropertySet > xParam;
941 OUString sParamName;
942 for ( sal_Int32 i=0; i<count; ++i )
943 {
944 xParam.set( xParams->getByIndex(i), uno::UNO_QUERY_THROW );
945 OSL_VERIFY( xParam->getPropertyValue( PROPERTY_NAME ) >>= sParamName );
946 pNames[i] = sParamName;
947 }
948 }
949 }
950 catch( const uno::Exception& )
951 {
952 DBG_UNHANDLED_EXCEPTION("reportdesign");
953 }
954
955 return aNames;
956}
957
959{
960 if (_pControl)
961 {
962 uno::Reference< report::XReportComponent > xComponent( _pControl->getUnoShape(), uno::UNO_QUERY);
963 if (xComponent.is())
964 {
965 tools::Rectangle aRect(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
966 aRect.setHeight(aRect.getOpenHeight() + 1);
967 aRect.setWidth(aRect.getOpenWidth() + 1);
968 return aRect;
969 }
970 }
971 return tools::Rectangle();
972}
973
974// check overlapping
975void correctOverlapping(SdrObject* _pControl,OReportSection const & _aReportSection,bool _bInsert)
976{
977 OSectionView& rSectionView = _aReportSection.getSectionView();
978 uno::Reference< report::XReportComponent> xComponent(_pControl->getUnoShape(),uno::UNO_QUERY);
979 tools::Rectangle aRect = getRectangleFromControl(_pControl);
980
981 bool bOverlapping = true;
982 while ( bOverlapping )
983 {
984 SdrObject* pOverlappedObj = isOver(aRect,*_aReportSection.getPage(),rSectionView,true, _pControl);
985 bOverlapping = pOverlappedObj != nullptr;
986 if ( bOverlapping )
987 {
988 const tools::Rectangle& aLogicRect = pOverlappedObj->GetLogicRect();
989 aRect.Move(0,aLogicRect.Top() + aLogicRect.getOpenHeight() - aRect.Top());
990 xComponent->setPositionY(aRect.Top());
991 }
992 }
993 if (_bInsert) // now insert objects
994 rSectionView.InsertObjectAtView(_pControl,*rSectionView.GetSdrPageView(), SdrInsertFlags::ADDMARK);
995}
996
997void setZoomFactor(const Fraction& _aZoom, vcl::Window& _rWindow)
998{
999 MapMode aMapMode( _rWindow.GetMapMode() );
1000 aMapMode.SetScaleX(_aZoom);
1001 aMapMode.SetScaleY(_aZoom);
1002 _rWindow.SetMapMode(aMapMode);
1003}
1004
1005bool openDialogFormula_nothrow( OUString& _in_out_rFormula
1006 , const css::uno::Reference< css::uno::XComponentContext >& _xContext
1007 , const uno::Reference< awt::XWindow>& _xInspectorWindow
1008 , const css::uno::Reference < css::beans::XPropertySet >& _xRowSet
1009 )
1010{
1011 OSL_PRECOND( _xInspectorWindow.is(), "openDialogFormula_nothrow: invalid parameters!" );
1012 if ( !_xInspectorWindow.is() )
1013 return false;
1014 bool bSuccess = false;
1015 ::dbtools::SQLExceptionInfo aErrorInfo;
1016 uno::Reference< awt::XWindow > xInspectorWindow;
1017 uno::Reference< lang::XMultiComponentFactory > xFactory;
1018 uno::Reference<lang::XMultiServiceFactory> xServiceFactory;
1019 try
1020 {
1021 xFactory = _xContext->getServiceManager();
1022 xServiceFactory.set(xFactory,uno::UNO_QUERY);
1023
1024 uno::Reference< report::meta::XFunctionManager> xMgr(xFactory->createInstanceWithContext("org.libreoffice.report.pentaho.SOFunctionManager",_xContext),uno::UNO_QUERY);
1025 if ( xMgr.is() )
1026 {
1027 auto pFormulaManager = std::make_shared<FunctionManager>(xMgr);
1028 ReportFormula aFormula( _in_out_rFormula );
1029
1031 svl::SharedStringPool aStringPool(aCC);
1032
1033 FormulaDialog aDlg(
1034 Application::GetFrameWeld(_xInspectorWindow), xServiceFactory, pFormulaManager,
1035 aFormula.getUndecoratedContent(), _xRowSet, aStringPool);
1036
1037 bSuccess = aDlg.run() == RET_OK;
1038 if ( bSuccess )
1039 {
1040 OUString sFormula = aDlg.getCurrentFormula();
1041 if ( sFormula[0] == '=' )
1042 _in_out_rFormula = OUString::Concat("rpt:") + sFormula.subView(1);
1043 else
1044 _in_out_rFormula = "rpt:" + sFormula;
1045 }
1046 }
1047 }
1048 catch (const sdb::SQLContext& e) { aErrorInfo = e; }
1049 catch (const sdbc::SQLWarning& e) { aErrorInfo = e; }
1050 catch (const sdbc::SQLException& e) { aErrorInfo = e; }
1051 catch( const uno::Exception& )
1052 {
1053 TOOLS_WARN_EXCEPTION( "reportdesign", "GeometryHandler::impl_dialogFilter_nothrow" );
1054 }
1055
1056 if ( aErrorInfo.isValid() )
1057 ::dbtools::showError( aErrorInfo, xInspectorWindow, _xContext );
1058
1059 return bSuccess;
1060}
1061
1062} // namespace rptui
1063
1064
1065/* 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:172
#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:170
#define ITEMID_WEIGHT_COMPLEX
Definition: UITools.cxx:166
#define ITEMID_ESCAPEMENT
Definition: UITools.cxx:143
#define ASIAN
Definition: UITools.cxx:171
#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:958
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:975
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:834
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:844
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:997
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:874
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
constexpr OUStringLiteral PROPERTY_CHARCOMBINEISON
Definition: strings.hxx:227
constexpr OUStringLiteral PROPERTY_CHARCOMBINESUFFIX
Definition: strings.hxx:229
constexpr OUStringLiteral PROPERTY_CHARESCAPEMENT
Definition: strings.hxx:225
constexpr OUStringLiteral PROPERTY_CHARCONTOURED
Definition: strings.hxx:232
constexpr OUStringLiteral PROPERTY_NAME
Definition: strings.hxx:36
constexpr OUStringLiteral PROPERTY_VERTICALALIGN
Definition: strings.hxx:86
constexpr OUStringLiteral PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
constexpr OUStringLiteral PROPERTY_CHARCOLOR
Definition: strings.hxx:85
constexpr OUStringLiteral PROPERTY_CHARSHADOWED
Definition: strings.hxx:231
constexpr OUStringLiteral PROPERTY_CHARFLASH
Definition: strings.hxx:222
constexpr OUStringLiteral PROPERTY_CHARAUTOKERNING
Definition: strings.hxx:233
constexpr OUStringLiteral PROPERTY_CHAREMPHASIS
Definition: strings.hxx:135
constexpr OUStringLiteral PROPERTY_CHARUNDERLINECOLOR
Definition: strings.hxx:88
constexpr OUStringLiteral PROPERTY_CHARLOCALECOMPLEX
Definition: strings.hxx:179
constexpr OUStringLiteral PROPERTY_CHARHIDDEN
Definition: strings.hxx:230
constexpr OUStringLiteral PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
constexpr OUStringLiteral PROPERTY_PARAADJUST
Definition: strings.hxx:79
constexpr OUStringLiteral PROPERTY_CHARCASEMAP
Definition: strings.hxx:226
constexpr OUStringLiteral PROPERTY_BACKCOLOR
Definition: strings.hxx:38
constexpr OUStringLiteral PROPERTY_CHARCOMBINEPREFIX
Definition: strings.hxx:228
constexpr OUStringLiteral PROPERTY_CHARRELIEF
Definition: strings.hxx:84
constexpr OUStringLiteral PROPERTY_CHARESCAPEMENTHEIGHT
Definition: strings.hxx:223
constexpr OUStringLiteral PROPERTY_CHARKERNING
Definition: strings.hxx:234
constexpr OUStringLiteral PROPERTY_CHARLOCALE
Definition: strings.hxx:224
constexpr OUStringLiteral PROPERTY_PAPERSIZE
Definition: strings.hxx:62
constexpr OUStringLiteral PROPERTY_CONTROLBACKGROUND
Definition: strings.hxx:40
constexpr OUStringLiteral PROPERTY_CHARLOCALEASIAN
Definition: strings.hxx:163
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