1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: UITools.cxx,v $
10 * $Revision: 1.7.36.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
33 #include <toolkit/helper/convert.hxx>
34 #include <toolkit/helper/vclunohelper.hxx>
35 #include "SectionView.hxx"
36 #include "UITools.hxx"
37 #include "Formula.hxx"
38 #include "FunctionHelper.hxx"
39 #include "reportformula.hxx"
41 #include <tools/diagnose_ex.h>
42 #include <tools/string.hxx>
44 #include <vcl/svapp.hxx>
45 #include <vcl/window.hxx>
46 #include <com/sun/star/lang/NullPointerException.hpp>
47 #include <com/sun/star/beans/NamedValue.hpp>
48 #include <com/sun/star/beans/PropertyAttribute.hpp>
50 #include <svx/charscaleitem.hxx>
51 #include <svx/algitem.hxx>
52 #include <svx/svdpagv.hxx>
53 #include <svx/xtable.hxx> // XColorTable
54 #include <svx/brshitem.hxx>
55 #include <svx/fontitem.hxx>
56 #include <svx/emphitem.hxx>
57 #include <svx/postitem.hxx>
58 #include <svx/udlnitem.hxx>
59 #include <svx/crsditem.hxx>
60 #include <svx/cntritem.hxx>
61 #include <svx/langitem.hxx>
62 #include <svx/wghtitem.hxx>
63 #include <svx/fhgtitem.hxx>
64 #include <svx/shdditem.hxx>
65 #include <svx/escpitem.hxx>
66 #include <svx/prszitem.hxx>
67 #include <svx/wrlmitem.hxx>
68 #include <svx/cmapitem.hxx>
69 #include <svx/kernitem.hxx>
70 #include <svx/blnkitem.hxx>
71 #include <svx/flstitem.hxx>
72 #include <svx/akrnitem.hxx>
73 #include <svx/colritem.hxx>
74 #include <svx/drawitem.hxx>
75 #include <svx/twolinesitem.hxx>
76 #include <svx/charreliefitem.hxx>
77 #include <svx/charrotateitem.hxx>
78 #include <svx/charhiddenitem.hxx>
79 #include <svx/xgrscit.hxx>
80 #include <svx/svditer.hxx>
81 #include <svx/xtable.hxx>
82 #include <svx/dialogs.hrc>
83 #include <svx/svdview.hxx>
84 #include <svx/svdpage.hxx>
85 #include <svx/svxdlg.hxx>
86 #include <svx/unoprov.hxx>
88 #include <svtools/pathoptions.hxx>
89 #include <svtools/ctrltool.hxx>
90 #include <svtools/itempool.hxx>
91 #include <svtools/itemset.hxx>
93 #include <comphelper/propmultiplex.hxx>
94 #include <comphelper/namedvaluecollection.hxx>
96 #include <connectivity/dbexception.hxx>
97 #include <connectivity/dbconversion.hxx>
98 #include <connectivity/dbtools.hxx>
100 #include <com/sun/star/report/XGroups.hpp>
101 #include <com/sun/star/awt/TextAlign.hpp>
102 #include <com/sun/star/style/VerticalAlignment.hpp>
103 #include <com/sun/star/report/XShape.hpp>
104 #include <com/sun/star/report/Function.hpp>
105 #include <com/sun/star/sdb/XParametersSupplier.hpp>
106 #include <com/sun/star/sdb/SQLContext.hpp>
107 #include <i18npool/mslangid.hxx>
108 #include "dlgpage.hxx"
109 #include <vcl/msgbox.hxx>
110 #include "rptui_slotid.hrc"
111 #include "uistrings.hrc"
112 #include "RptObject.hxx"
113 #include "ModuleHelper.hxx"
114 #include "RptDef.hxx"
115 #include "RptResId.hrc"
116 #include "ReportDefinition.hxx"
117 #include "RptModel.hxx"
119 #define ITEMID_FONT 10
120 #define ITEMID_FONTHEIGHT 11
121 #define ITEMID_LANGUAGE 12
123 #define ITEMID_POSTURE 13
124 #define ITEMID_WEIGHT 14
125 #define ITEMID_SHADOWED 15
126 #define ITEMID_WORDLINEMODE 16
127 #define ITEMID_CONTOUR 17
128 #define ITEMID_CROSSEDOUT 18
129 #define ITEMID_UNDERLINE 19
131 #define ITEMID_COLOR 20
132 #define ITEMID_KERNING 21
133 #define ITEMID_CASEMAP 22
135 #define ITEMID_ESCAPEMENT 23
136 #define ITEMID_FONTLIST 24
137 #define ITEMID_AUTOKERN 25
138 #define ITEMID_COLOR_TABLE 26
139 #define ITEMID_BLINK 27
140 #define ITEMID_EMPHASISMARK 28
141 #define ITEMID_TWOLINES 29
142 #define ITEMID_CHARROTATE 30
143 #define ITEMID_CHARSCALE_W 31
144 #define ITEMID_CHARRELIEF 32
145 #define ITEMID_CHARHIDDEN 33
146 #define ITEMID_BRUSH 34
147 #define ITEMID_HORJUSTIFY 35
148 #define ITEMID_VERJUSTIFY 36
149 #define ITEMID_FONT_ASIAN 37
150 #define ITEMID_FONTHEIGHT_ASIAN 38
151 #define ITEMID_LANGUAGE_ASIAN 39
152 #define ITEMID_POSTURE_ASIAN 40
153 #define ITEMID_WEIGHT_ASIAN 41
154 #define ITEMID_FONT_COMPLEX 42
155 #define ITEMID_FONTHEIGHT_COMPLEX 43
156 #define ITEMID_LANGUAGE_COMPLEX 44
157 #define ITEMID_POSTURE_COMPLEX 45
158 #define ITEMID_WEIGHT_COMPLEX 46
166 using namespace ::com::sun::star
;
167 using namespace formula
;
168 // -----------------------------------------------------------------------------
169 void adjustSectionName(const uno::Reference
< report::XGroup
>& _xGroup
,sal_Int32 _nPos
)
171 OSL_ENSURE(_xGroup
.is(),"Group is NULL -> GPF");
172 if ( _xGroup
->getHeaderOn() && !_xGroup
->getHeader()->getName().getLength() )
174 ::rtl::OUString sName
= String(ModuleRes(RID_STR_GROUPHEADER
));
175 sName
+= ::rtl::OUString::valueOf(_nPos
);
176 _xGroup
->getHeader()->setName(sName
);
177 } // if ( _xGroup->getHeaderOn() )
179 if ( _xGroup
->getFooterOn() && !_xGroup
->getFooter()->getName().getLength() )
181 ::rtl::OUString sName
= String(ModuleRes(RID_STR_GROUPFOOTER
));
182 sName
+= ::rtl::OUString::valueOf(_nPos
);
183 _xGroup
->getFooter()->setName(sName
);
184 } // if ( _xGroup->getHeaderOn() )
186 // -----------------------------------------------------------------------------
187 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> addStyleListener(const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
,::comphelper::OPropertyChangeListener
* _pListener
)
189 ::rtl::Reference
< comphelper::OPropertyChangeMultiplexer
> pRet
= NULL
;
190 if ( _xReportDefinition
.is() )
192 uno::Reference
<beans::XPropertySet
> xPageStyle(getUsedStyle(_xReportDefinition
),uno::UNO_QUERY
);
193 if ( xPageStyle
.is() )
195 pRet
= new comphelper::OPropertyChangeMultiplexer(_pListener
,xPageStyle
);
196 pRet
->addProperty(PROPERTY_LEFTMARGIN
);
197 pRet
->addProperty(PROPERTY_RIGHTMARGIN
);
198 pRet
->addProperty(PROPERTY_PAPERSIZE
);
199 pRet
->addProperty(PROPERTY_BACKCOLOR
);
205 // -----------------------------------------------------------------------------
208 // -------------------------------------------------------------------------
209 Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
, awt::FontDescriptor
& _out_rControlFont
,USHORT _nWichFont
)
211 if ( !_rxReportControlFormat
.is() )
212 throw uno::RuntimeException();
217 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptor();
220 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorAsian();
223 _out_rControlFont
= _rxReportControlFormat
->getFontDescriptorComplex();
228 Font aDefaultFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
229 return VCLUnoHelper::CreateFont( _out_rControlFont
, aDefaultFont
);
232 // -------------------------------------------------------------------------
233 Font
lcl_getReportControlFont( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,USHORT _nWhich
)
235 awt::FontDescriptor aAwtFont
;
236 return lcl_getReportControlFont( _rxReportControlFormat
, aAwtFont
, _nWhich
);
238 // -------------------------------------------------------------------------
239 const Font
lcl_setFont(const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
240 SfxItemSet
& _rItemSet
,USHORT _nWhich
,USHORT _nFont
, USHORT _nFontHeight
,USHORT _nLanguage
,USHORT _nPosture
, USHORT _nWeight
)
243 awt::FontDescriptor aControlFont
;
244 const Font
aFont( lcl_getReportControlFont( _rxReportControlFormat
, aControlFont
,_nWhich
) );
246 SvxFontItem
aFontItem(_nFont
);
247 aFontItem
.PutValue( uno::makeAny( aControlFont
) );
248 _rItemSet
.Put(aFontItem
);
250 _rItemSet
.Put(SvxFontHeightItem(OutputDevice::LogicToLogic(Size(0, (sal_Int32
)aFont
.GetHeight()), MAP_POINT
, MAP_TWIP
).Height(),100,_nFontHeight
));
251 lang::Locale aLocale
;
255 aLocale
= _rxReportControlFormat
->getCharLocale();
258 aLocale
= _rxReportControlFormat
->getCharLocaleAsian();
261 aLocale
= _rxReportControlFormat
->getCharLocaleComplex();
265 _rItemSet
.Put(SvxLanguageItem(MsLangId::convertLocaleToLanguageWithFallback(aLocale
),_nLanguage
));
267 _rItemSet
.Put(SvxPostureItem(aFont
.GetItalic(),_nPosture
));
268 _rItemSet
.Put(SvxWeightItem(aFont
.GetWeight(),_nWeight
));
272 void lcl_fillShapeToItems( const uno::Reference
<report::XShape
>& _xShape
,SfxItemSet
& _rItemSet
)
274 uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
275 SvxUnoPropertyMapProvider aMap
;
276 const SfxItemPropertyMap
* pPropertyMap
= aMap
.GetPropertySet(SVXMAP_CUSTOMSHAPE
)->getPropertyMap();
277 PropertyEntryVector_t aPropVector
= pPropertyMap
->getPropertyEntries();
278 PropertyEntryVector_t::const_iterator aIt
= aPropVector
.begin();
279 while( aIt
!= aPropVector
.end() )
281 if ( xInfo
->hasPropertyByName(aIt
->sName
) )
283 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(aIt
->nWID
);
286 ::std::auto_ptr
<SfxPoolItem
> pClone(pItem
->Clone());
287 pClone
->PutValue(_xShape
->getPropertyValue(aIt
->sName
), aIt
->nMemberId
);
288 _rItemSet
.Put(*pClone
, aIt
->nWID
);
290 } // if ( xInfo->hasPropertyByName(sPropertyName) )
295 void lcl_fillItemsToShape( const uno::Reference
<report::XShape
>& _xShape
,const SfxItemSet
& _rItemSet
)
297 const uno::Reference
< beans::XPropertySetInfo
> xInfo
= _xShape
->getPropertySetInfo();
298 SvxUnoPropertyMapProvider aMap
;
299 const SfxItemPropertyMap
* pPropertyMap
= aMap
.GetPropertySet(SVXMAP_CUSTOMSHAPE
)->getPropertyMap();
300 PropertyEntryVector_t aPropVector
= pPropertyMap
->getPropertyEntries();
301 PropertyEntryVector_t::const_iterator aIt
= aPropVector
.begin();
302 while( aIt
!= aPropVector
.end() )
304 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState(aIt
->nWID
) && xInfo
->hasPropertyByName(aIt
->sName
) )
306 const beans::Property aProp
= xInfo
->getPropertyByName( aIt
->sName
);
307 if ( ( aIt
->nFlags
& beans::PropertyAttribute::READONLY
) != beans::PropertyAttribute::READONLY
)
309 const SfxPoolItem
* pItem
= _rItemSet
.GetItem(aIt
->nWID
);
313 pItem
->QueryValue(aValue
,aIt
->nMemberId
);
316 _xShape
->setPropertyValue(aIt
->sName
, aValue
);
318 catch(uno::Exception
&)
319 { // shapes have a bug so we ignore this one.
325 } // while ( pPropertyMap->pName )
327 // -------------------------------------------------------------------------
328 void lcl_CharPropertiesToItems( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
329 SfxItemSet
& _rItemSet
)
331 if ( !_rxReportControlFormat
.is() )
332 throw lang::NullPointerException();
334 uno::Reference
< beans::XPropertySet
> xSet(_rxReportControlFormat
,uno::UNO_QUERY_THROW
);
337 const Font
aFont( lcl_setFont(_rxReportControlFormat
, _rItemSet
,WESTERN
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_LANGUAGE
,ITEMID_POSTURE
,ITEMID_WEIGHT
) );
339 _rItemSet
.Put(SvxShadowedItem(_rxReportControlFormat
->getCharShadowed(),ITEMID_SHADOWED
));
340 _rItemSet
.Put(SvxWordLineModeItem(aFont
.IsWordLineMode(),ITEMID_WORDLINEMODE
));
341 _rItemSet
.Put(SvxContourItem(_rxReportControlFormat
->getCharContoured(),ITEMID_CONTOUR
));
342 _rItemSet
.Put(SvxAutoKernItem(_rxReportControlFormat
->getCharAutoKerning(),ITEMID_AUTOKERN
));
343 _rItemSet
.Put(SvxCrossedOutItem(aFont
.GetStrikeout(),ITEMID_CROSSEDOUT
));
344 _rItemSet
.Put(SvxCaseMapItem(static_cast<SvxCaseMap
>(_rxReportControlFormat
->getCharCaseMap()),ITEMID_CASEMAP
));
346 _rItemSet
.Put(SvxEscapementItem(_rxReportControlFormat
->getCharEscapement(),_rxReportControlFormat
->getCharEscapementHeight(),ITEMID_ESCAPEMENT
));
347 _rItemSet
.Put(SvxBlinkItem(_rxReportControlFormat
->getCharFlash(),ITEMID_BLINK
));
348 _rItemSet
.Put(SvxCharHiddenItem(_rxReportControlFormat
->getCharHidden(),ITEMID_CHARHIDDEN
));
349 _rItemSet
.Put(SvxTwoLinesItem(_rxReportControlFormat
->getCharCombineIsOn(),_rxReportControlFormat
->getCharCombinePrefix().toChar(),_rxReportControlFormat
->getCharCombineSuffix().toChar(),ITEMID_TWOLINES
));
350 SvxUnderlineItem
aUnderLineItem(aFont
.GetUnderline(),ITEMID_UNDERLINE
);
351 aUnderLineItem
.SetColor(_rxReportControlFormat
->getCharUnderlineColor());
352 _rItemSet
.Put(aUnderLineItem
);
353 _rItemSet
.Put(SvxKerningItem(_rxReportControlFormat
->getCharKerning(),ITEMID_KERNING
));
354 _rItemSet
.Put(SvxEmphasisMarkItem(static_cast<FontEmphasisMark
>(_rxReportControlFormat
->getCharEmphasis()),ITEMID_EMPHASISMARK
));
355 //_rItemSet.Put(SvxTwoLinesItem());
356 _rItemSet
.Put(SvxCharReliefItem(static_cast<FontRelief
>(_rxReportControlFormat
->getCharRelief()),ITEMID_CHARRELIEF
));
357 _rItemSet
.Put(SvxColorItem(::Color(_rxReportControlFormat
->getCharColor()),ITEMID_COLOR
));
358 _rItemSet
.Put(SvxCharRotateItem(_rxReportControlFormat
->getCharRotation(),sal_False
,ITEMID_CHARROTATE
));
359 _rItemSet
.Put(SvxCharScaleWidthItem(_rxReportControlFormat
->getCharScaleWidth(),ITEMID_CHARSCALE_W
));
361 SvxHorJustifyItem
aHorJustifyItem(ITEMID_HORJUSTIFY
);
362 aHorJustifyItem
.PutValue(xSet
->getPropertyValue(PROPERTY_PARAADJUST
),MID_HORJUST_ADJUST
);
363 _rItemSet
.Put(aHorJustifyItem
);
364 //_rItemSet.Put(SfxInt32Item(ITEMID_DEGREES,_rxReportControlFormat->getCharRotation()));
365 SvxVerJustifyItem
aVerJustifyItem(ITEMID_VERJUSTIFY
);
366 aVerJustifyItem
.PutValue(xSet
->getPropertyValue(PROPERTY_VERTICALALIGN
),MID_HORJUST_ADJUST
);
367 _rItemSet
.Put(aVerJustifyItem
);
368 //_rItemSet.Put(SfxInt32Item(ITEMID_IDENT,_rxReportControlFormat->getCharRotation()));
370 uno::Reference
< report::XShape
> xShape(_rxReportControlFormat
,uno::UNO_QUERY
);
372 _rItemSet
.Put(SvxBrushItem(::Color(_rxReportControlFormat
->getControlBackground()),ITEMID_BRUSH
));
374 lcl_setFont(_rxReportControlFormat
, _rItemSet
,ASIAN
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_LANGUAGE_ASIAN
,ITEMID_POSTURE_ASIAN
,ITEMID_WEIGHT_ASIAN
);
375 lcl_setFont(_rxReportControlFormat
, _rItemSet
,COMPLEX
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_LANGUAGE_COMPLEX
,ITEMID_POSTURE_COMPLEX
,ITEMID_WEIGHT_COMPLEX
);
378 // -------------------------------------------------------------------------
379 void lcl_pushBack( uno::Sequence
< beans::NamedValue
>& _out_rProperties
, const ::rtl::OUString
& _sName
, const uno::Any
& _rValue
)
381 sal_Int32
nLen( _out_rProperties
.getLength() );
382 _out_rProperties
.realloc( nLen
+ 1 );
383 _out_rProperties
[ nLen
] = beans::NamedValue( _sName
, _rValue
);
386 // -------------------------------------------------------------------------
387 void lcl_initAwtFont( const Font
& _rOriginalFont
, const SfxItemSet
& _rItemSet
, awt::FontDescriptor
& _out_rAwtFont
,
388 USHORT _nFont
, USHORT _nFontHeight
,USHORT _nPosture
, USHORT _nWeight
)
390 Font
aNewFont( _rOriginalFont
);
391 const SfxPoolItem
* pItem( NULL
);
392 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nFont
,sal_True
,&pItem
) && pItem
->ISA(SvxFontItem
))
394 const SvxFontItem
* pFontItem
= static_cast<const SvxFontItem
*>(pItem
);
395 aNewFont
.SetName( pFontItem
->GetFamilyName());
396 aNewFont
.SetStyleName(pFontItem
->GetStyleName());
397 aNewFont
.SetFamily(pFontItem
->GetFamily());
398 aNewFont
.SetPitch(pFontItem
->GetPitch());
399 aNewFont
.SetCharSet(pFontItem
->GetCharSet());
400 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_FONT,sal_True,&pItem) && pItem->ISA(SvxFontItem))
401 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nFontHeight
,sal_True
,&pItem
) && pItem
->ISA(SvxFontHeightItem
))
403 const SvxFontHeightItem
* pFontItem
= static_cast<const SvxFontHeightItem
*>(pItem
);
404 aNewFont
.SetHeight(OutputDevice::LogicToLogic(Size(0, pFontItem
->GetHeight()), MAP_TWIP
, MAP_POINT
).Height());
406 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nPosture
,sal_True
,&pItem
) && pItem
->ISA(SvxPostureItem
))
408 const SvxPostureItem
* pFontItem
= static_cast<const SvxPostureItem
*>(pItem
);
409 aNewFont
.SetItalic(pFontItem
->GetPosture());
411 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( _nWeight
,sal_True
,&pItem
) && pItem
->ISA(SvxWeightItem
))
413 const SvxWeightItem
* pFontItem
= static_cast<const SvxWeightItem
*>(pItem
);
414 aNewFont
.SetWeight(pFontItem
->GetWeight());
416 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_WORDLINEMODE
,sal_True
,&pItem
) && pItem
->ISA(SvxWordLineModeItem
))
418 const SvxWordLineModeItem
* pFontItem
= static_cast<const SvxWordLineModeItem
*>(pItem
);
419 aNewFont
.SetWordLineMode(pFontItem
->GetValue());
421 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CROSSEDOUT
,sal_True
,&pItem
) && pItem
->ISA(SvxCrossedOutItem
))
423 const SvxCrossedOutItem
* pFontItem
= static_cast<const SvxCrossedOutItem
*>(pItem
);
424 aNewFont
.SetStrikeout(pFontItem
->GetStrikeout());
427 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARROTATE
,sal_True
,&pItem
) && pItem
->ISA(SvxCharRotateItem
))
429 const SvxCharRotateItem
* pRotateItem
= static_cast<const SvxCharRotateItem
*>(pItem
);
430 aNewFont
.SetOrientation(pRotateItem
->GetValue());
432 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARSCALE_W
,sal_True
,&pItem
) && pItem
->ISA(SvxCharScaleWidthItem
))
434 const SvxCharScaleWidthItem
* pCharItem
= static_cast<const SvxCharScaleWidthItem
*>(pItem
);
435 aNewFont
.SetWidthType(VCLUnoHelper::ConvertFontWidth(pCharItem
->GetValue()));
437 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_UNDERLINE
,sal_True
,&pItem
) && pItem
->ISA(SvxUnderlineItem
))
439 const SvxUnderlineItem
* pFontItem
= static_cast<const SvxUnderlineItem
*>(pItem
);
440 aNewFont
.SetUnderline(pFontItem
->GetLineStyle());
442 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_COLOR
,sal_True
,&pItem
) && pItem
->ISA(SvxColorItem
))
444 const SvxColorItem
* pFontItem
= static_cast<const SvxColorItem
*>(pItem
);
445 aNewFont
.SetColor(pFontItem
->GetValue().GetColor());
448 _out_rAwtFont
= VCLUnoHelper::CreateFontDescriptor( aNewFont
);
451 // -------------------------------------------------------------------------
452 void lcl_itemsToCharProperties( const Font
& _rOriginalControlFont
,const Font
& _rOriginalControlFontAsian
,const Font
& _rOriginalControlFontComplex
, const SfxItemSet
& _rItemSet
, uno::Sequence
< beans::NamedValue
>& _out_rProperties
)
454 const SfxPoolItem
* pItem( NULL
);
456 // create an AWT font
457 awt::FontDescriptor aAwtFont
;
458 lcl_initAwtFont( _rOriginalControlFont
, _rItemSet
, aAwtFont
,ITEMID_FONT
,ITEMID_FONTHEIGHT
,ITEMID_POSTURE
, ITEMID_WEIGHT
);
459 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Font")), uno::makeAny( aAwtFont
) );
460 lcl_initAwtFont( _rOriginalControlFontAsian
, _rItemSet
, aAwtFont
,ITEMID_FONT_ASIAN
,ITEMID_FONTHEIGHT_ASIAN
,ITEMID_POSTURE_ASIAN
, ITEMID_WEIGHT_ASIAN
);
461 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontAsian")), uno::makeAny( aAwtFont
) );
462 lcl_initAwtFont( _rOriginalControlFontComplex
, _rItemSet
, aAwtFont
,ITEMID_FONT_COMPLEX
,ITEMID_FONTHEIGHT_COMPLEX
,ITEMID_POSTURE_COMPLEX
, ITEMID_WEIGHT_COMPLEX
);
463 lcl_pushBack( _out_rProperties
, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FontComplex")), uno::makeAny( aAwtFont
) );
465 // properties which cannot be represented in an AWT font need to be preserved directly
466 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_SHADOWED
,sal_True
,&pItem
) && pItem
->ISA(SvxShadowedItem
))
468 const SvxShadowedItem
* pFontItem
= static_cast<const SvxShadowedItem
*>(pItem
);
469 lcl_pushBack( _out_rProperties
, PROPERTY_CHARSHADOWED
, uno::makeAny( pFontItem
->GetValue() ) );
471 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CONTOUR
,sal_True
,&pItem
) && pItem
->ISA(SvxContourItem
))
473 const SvxContourItem
* pFontItem
= static_cast<const SvxContourItem
*>(pItem
);
474 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCONTOURED
, uno::makeAny( pFontItem
->GetValue() ) );
476 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_UNDERLINE
,sal_True
,&pItem
) && pItem
->ISA(SvxUnderlineItem
))
478 const SvxUnderlineItem
* pFontItem
= static_cast<const SvxUnderlineItem
*>(pItem
);
479 lcl_pushBack( _out_rProperties
, PROPERTY_CHARUNDERLINECOLOR
, uno::makeAny( pFontItem
->GetColor().GetColor() ) );
481 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_HORJUSTIFY
,sal_True
,&pItem
) && pItem
->ISA(SvxHorJustifyItem
))
483 const SvxHorJustifyItem
* pJustifyItem
= static_cast<const SvxHorJustifyItem
*>(pItem
);
485 pJustifyItem
->QueryValue(aValue
,MID_HORJUST_ADJUST
);
486 lcl_pushBack( _out_rProperties
, PROPERTY_PARAADJUST
, aValue
);
488 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_VERJUSTIFY
,sal_True
,&pItem
) && pItem
->ISA(SvxVerJustifyItem
))
490 const SvxVerJustifyItem
* pJustifyItem
= static_cast<const SvxVerJustifyItem
*>(pItem
);
492 pJustifyItem
->QueryValue(aValue
,MID_HORJUST_ADJUST
);
493 lcl_pushBack( _out_rProperties
, PROPERTY_VERTICALALIGN
, aValue
);
495 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARRELIEF
,sal_True
,&pItem
) && pItem
->ISA(SvxCharReliefItem
))
497 const SvxCharReliefItem
* pFontItem
= static_cast<const SvxCharReliefItem
*>(pItem
);
498 lcl_pushBack( _out_rProperties
, PROPERTY_CHARRELIEF
, uno::makeAny( static_cast< sal_Int16
>( pFontItem
->GetEnumValue() ) ) );
500 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CHARHIDDEN
,sal_True
,&pItem
) && pItem
->ISA(SvxCharHiddenItem
))
502 const SvxCharHiddenItem
* pFontItem
= static_cast<const SvxCharHiddenItem
*>(pItem
);
503 lcl_pushBack( _out_rProperties
, PROPERTY_CHARHIDDEN
, uno::makeAny( pFontItem
->GetValue() ) );
505 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_AUTOKERN
,sal_True
,&pItem
) && pItem
->ISA(SvxAutoKernItem
))
507 const SvxAutoKernItem
* pFontItem
= static_cast<const SvxAutoKernItem
*>(pItem
);
508 lcl_pushBack( _out_rProperties
, PROPERTY_CHARAUTOKERNING
, uno::makeAny( pFontItem
->GetValue() ) );
510 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_BRUSH
,sal_True
,&pItem
) && pItem
->ISA(SvxBrushItem
))
512 const SvxBrushItem
* pFontItem
= static_cast<const SvxBrushItem
*>(pItem
);
513 lcl_pushBack( _out_rProperties
, PROPERTY_CONTROLBACKGROUND
, uno::makeAny( pFontItem
->GetColor().GetColor() ) );
515 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_BLINK
,sal_True
,&pItem
) && pItem
->ISA(SvxBlinkItem
))
517 const SvxBlinkItem
* pFontItem
= static_cast<const SvxBlinkItem
*>(pItem
);
518 lcl_pushBack( _out_rProperties
, PROPERTY_CHARFLASH
, uno::makeAny( pFontItem
->GetValue() ) );
520 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_EMPHASISMARK
,sal_True
,&pItem
) && pItem
->ISA(SvxEmphasisMarkItem
))
522 const SvxEmphasisMarkItem
* pFontItem
= static_cast<const SvxEmphasisMarkItem
*>(pItem
);
523 lcl_pushBack( _out_rProperties
, PROPERTY_CHAREMPHASIS
, uno::makeAny( static_cast< sal_Int16
>( pFontItem
->GetEmphasisMark() ) ) );
525 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_TWOLINES
,sal_True
,&pItem
) && pItem
->ISA(SvxTwoLinesItem
))
527 const SvxTwoLinesItem
* pFontItem
= static_cast<const SvxTwoLinesItem
*>(pItem
);
528 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEISON
, uno::makeAny( pFontItem
->GetValue() ) );
529 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINEPREFIX
, uno::makeAny( ::rtl::OUString( pFontItem
->GetStartBracket() ) ) );
530 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOMBINESUFFIX
, uno::makeAny( ::rtl::OUString( pFontItem
->GetEndBracket() ) ) );
532 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_COLOR
,sal_True
,&pItem
) && pItem
->ISA(SvxColorItem
))
534 const SvxColorItem
* pFontItem
= static_cast<const SvxColorItem
*>(pItem
);
535 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCOLOR
, uno::makeAny( pFontItem
->GetValue().GetColor() ) );
537 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_KERNING
,sal_True
,&pItem
) && pItem
->ISA(SvxKerningItem
))
539 const SvxKerningItem
* pFontItem
= static_cast<const SvxKerningItem
*>(pItem
);
540 lcl_pushBack( _out_rProperties
, PROPERTY_CHARKERNING
, uno::makeAny( pFontItem
->GetValue() ) );
542 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_CASEMAP
,sal_True
,&pItem
) && pItem
->ISA(SvxCaseMapItem
))
544 const SvxCaseMapItem
* pFontItem
= static_cast<const SvxCaseMapItem
*>(pItem
);
545 lcl_pushBack( _out_rProperties
, PROPERTY_CHARCASEMAP
, uno::makeAny( pFontItem
->GetValue() ) );
546 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_CASEMAP,sal_True,&pItem) && pItem->ISA(SvxCaseMapItem))
549 ::rtl::OUString sPropertyName
;
551 const Items pItems
[] = { {ITEMID_LANGUAGE
,PROPERTY_CHARLOCALE
}
552 ,{ITEMID_LANGUAGE_ASIAN
,PROPERTY_CHARLOCALEASIAN
}
553 ,{ITEMID_LANGUAGE_COMPLEX
,PROPERTY_CHARLOCALECOMPLEX
}
555 for(size_t k
= 0; k
< sizeof(pItems
)/sizeof(pItems
[0]);++k
)
557 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( pItems
[k
].nWhich
,sal_True
,&pItem
) && pItem
->ISA(SvxLanguageItem
))
559 const SvxLanguageItem
* pFontItem
= static_cast<const SvxLanguageItem
*>(pItem
);
560 lang::Locale aCharLocale
;
561 MsLangId::convertLanguageToLocale( pFontItem
->GetLanguage(), aCharLocale
);
562 lcl_pushBack( _out_rProperties
, pItems
[k
].sPropertyName
, uno::makeAny( aCharLocale
) );
563 } // if ( SFX_ITEM_SET == _rItemSet.GetItemState( ITEMID_LANGUAGE,sal_True,&pItem) && pItem->ISA(SvxLanguageItem))
565 if ( SFX_ITEM_SET
== _rItemSet
.GetItemState( ITEMID_ESCAPEMENT
,sal_True
,&pItem
) && pItem
->ISA(SvxEscapementItem
))
567 const SvxEscapementItem
* pFontItem
= static_cast<const SvxEscapementItem
*>(pItem
);
568 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENT
, uno::makeAny( pFontItem
->GetEsc() ) );
569 lcl_pushBack( _out_rProperties
, PROPERTY_CHARESCAPEMENTHEIGHT
, uno::makeAny( (sal_Int8
)pFontItem
->GetProp() ) );
573 // -------------------------------------------------------------------------
574 template< class ATTRIBUTE_TYPE
>
575 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
576 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
577 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( ATTRIBUTE_TYPE
) )
579 ATTRIBUTE_TYPE aAttributeValue
= ATTRIBUTE_TYPE();
580 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
581 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
584 // -------------------------------------------------------------------------
585 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
586 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
587 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const ::rtl::OUString
& ) )
589 ::rtl::OUString aAttributeValue
;
590 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
591 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
594 // -------------------------------------------------------------------------
595 void lcl_applyFontAttribute( const ::comphelper::NamedValueCollection
& _rAttrValues
, const sal_Char
* _pAttributeName
,
596 const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
597 void (SAL_CALL
report::XReportControlFormat::*pSetter
)( const lang::Locale
& ) )
599 lang::Locale aAttributeValue
;
600 if ( _rAttrValues
.get_ensureType( _pAttributeName
, aAttributeValue
) )
601 (_rxReportControlFormat
.get()->*pSetter
)( aAttributeValue
);
605 // -----------------------------------------------------------------------------
606 bool openCharDialog( const uno::Reference
<report::XReportControlFormat
>& _rxReportControlFormat
,
607 const uno::Reference
< awt::XWindow
>& _rxParentWindow
, uno::Sequence
< beans::NamedValue
>& _out_rNewValues
)
609 OSL_PRECOND( _rxReportControlFormat
.is() && _rxParentWindow
.is(), "openCharDialog: invalid parameters!" );
610 if ( !_rxReportControlFormat
.is() || !_rxParentWindow
.is() )
613 _out_rNewValues
= uno::Sequence
< beans::NamedValue
>();
617 static SfxItemInfo aItemInfos
[] =
619 { SID_ATTR_CHAR_FONT
, SFX_ITEM_POOLABLE
},
620 { SID_ATTR_CHAR_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
621 { SID_ATTR_CHAR_LANGUAGE
, SFX_ITEM_POOLABLE
},
622 { SID_ATTR_CHAR_POSTURE
, SFX_ITEM_POOLABLE
},
623 { SID_ATTR_CHAR_WEIGHT
, SFX_ITEM_POOLABLE
},
624 { SID_ATTR_CHAR_SHADOWED
, SFX_ITEM_POOLABLE
},
625 { SID_ATTR_CHAR_WORDLINEMODE
, SFX_ITEM_POOLABLE
},
626 { SID_ATTR_CHAR_CONTOUR
, SFX_ITEM_POOLABLE
},
627 { SID_ATTR_CHAR_STRIKEOUT
, SFX_ITEM_POOLABLE
},
628 { SID_ATTR_CHAR_UNDERLINE
, SFX_ITEM_POOLABLE
},
629 { SID_ATTR_CHAR_COLOR
, SFX_ITEM_POOLABLE
},
630 { SID_ATTR_CHAR_KERNING
, SFX_ITEM_POOLABLE
},
631 { SID_ATTR_CHAR_CASEMAP
, SFX_ITEM_POOLABLE
},
632 { SID_ATTR_CHAR_ESCAPEMENT
, SFX_ITEM_POOLABLE
},
633 { SID_ATTR_CHAR_FONTLIST
, SFX_ITEM_POOLABLE
},
634 { SID_ATTR_CHAR_AUTOKERN
, SFX_ITEM_POOLABLE
},
635 { SID_COLOR_TABLE
, SFX_ITEM_POOLABLE
},
636 { SID_ATTR_FLASH
, SFX_ITEM_POOLABLE
},
637 { SID_ATTR_CHAR_EMPHASISMARK
, SFX_ITEM_POOLABLE
},
638 { SID_ATTR_CHAR_TWO_LINES
, SFX_ITEM_POOLABLE
},
639 { SID_ATTR_CHAR_ROTATED
, SFX_ITEM_POOLABLE
},
640 { SID_ATTR_CHAR_SCALEWIDTH
, SFX_ITEM_POOLABLE
},
641 { SID_ATTR_CHAR_RELIEF
, SFX_ITEM_POOLABLE
},
642 { SID_ATTR_CHAR_HIDDEN
, SFX_ITEM_POOLABLE
},
643 //{ SID_ATTR_BRUSH_CHAR, SFX_ITEM_POOLABLE },
644 { SID_ATTR_BRUSH
, SFX_ITEM_POOLABLE
},
645 { SID_ATTR_ALIGN_HOR_JUSTIFY
, SFX_ITEM_POOLABLE
},
646 { SID_ATTR_ALIGN_VER_JUSTIFY
, SFX_ITEM_POOLABLE
},
649 { SID_ATTR_CHAR_CJK_FONT
, SFX_ITEM_POOLABLE
},
650 { SID_ATTR_CHAR_CJK_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
651 { SID_ATTR_CHAR_CJK_LANGUAGE
, SFX_ITEM_POOLABLE
},
652 { SID_ATTR_CHAR_CJK_POSTURE
, SFX_ITEM_POOLABLE
},
653 { SID_ATTR_CHAR_CJK_WEIGHT
, SFX_ITEM_POOLABLE
},
655 { SID_ATTR_CHAR_CTL_FONT
, SFX_ITEM_POOLABLE
},
656 { SID_ATTR_CHAR_CTL_FONTHEIGHT
, SFX_ITEM_POOLABLE
},
657 { SID_ATTR_CHAR_CTL_LANGUAGE
, SFX_ITEM_POOLABLE
},
658 { SID_ATTR_CHAR_CTL_POSTURE
, SFX_ITEM_POOLABLE
},
659 { SID_ATTR_CHAR_CTL_WEIGHT
, SFX_ITEM_POOLABLE
}
661 Window
* pParent
= VCLUnoHelper::GetWindow( _rxParentWindow
);
662 ::std::auto_ptr
<FontList
> pFontList(new FontList( pParent
));
663 ::std::auto_ptr
<XColorTable
> pColorTable( new XColorTable( SvtPathOptions().GetPalettePath() ));
664 SfxPoolItem
* pDefaults
[] =
666 new SvxFontItem(ITEMID_FONT
),
667 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT
),
668 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE
),
669 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE
),
670 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT
),
672 new SvxShadowedItem(FALSE
,ITEMID_SHADOWED
),
673 new SvxWordLineModeItem(FALSE
,ITEMID_WORDLINEMODE
),
674 new SvxContourItem(FALSE
,ITEMID_CONTOUR
),
675 new SvxCrossedOutItem(STRIKEOUT_NONE
,ITEMID_CROSSEDOUT
),
676 new SvxUnderlineItem(UNDERLINE_NONE
,ITEMID_UNDERLINE
),
678 new SvxColorItem(ITEMID_COLOR
),
679 new SvxKerningItem(0,ITEMID_KERNING
),
680 new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
,ITEMID_CASEMAP
),
681 new SvxEscapementItem(ITEMID_ESCAPEMENT
),
682 new SvxFontListItem(pFontList
.get(),ITEMID_FONTLIST
),
683 new SvxAutoKernItem(FALSE
,ITEMID_AUTOKERN
),
684 new SvxColorTableItem(pColorTable
.get(),ITEMID_COLOR_TABLE
),
685 new SvxBlinkItem(FALSE
,ITEMID_BLINK
),
686 new SvxEmphasisMarkItem(EMPHASISMARK_NONE
,ITEMID_EMPHASISMARK
),
687 new SvxTwoLinesItem(TRUE
,0,0,ITEMID_TWOLINES
),
688 new SvxCharRotateItem(0,sal_False
,ITEMID_CHARROTATE
),
689 new SvxCharScaleWidthItem(100,ITEMID_CHARSCALE_W
),
690 new SvxCharReliefItem(RELIEF_NONE
,ITEMID_CHARRELIEF
),
691 new SvxCharHiddenItem(FALSE
,ITEMID_CHARHIDDEN
),
692 new SvxBrushItem(ITEMID_BRUSH
),
693 new SvxHorJustifyItem(ITEMID_HORJUSTIFY
),
694 new SvxVerJustifyItem(ITEMID_VERJUSTIFY
),
696 new SvxFontItem(ITEMID_FONT_ASIAN
),
697 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_ASIAN
),
698 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_ASIAN
),
699 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_ASIAN
),
700 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_ASIAN
),
702 new SvxFontItem(ITEMID_FONT_COMPLEX
),
703 new SvxFontHeightItem(240,100,ITEMID_FONTHEIGHT_COMPLEX
),
704 new SvxLanguageItem(LANGUAGE_GERMAN
,ITEMID_LANGUAGE_COMPLEX
),
705 new SvxPostureItem(ITALIC_NONE
,ITEMID_POSTURE_COMPLEX
),
706 new SvxWeightItem(WEIGHT_NORMAL
,ITEMID_WEIGHT_COMPLEX
)
710 OSL_ASSERT((sizeof(pDefaults
)/sizeof(pDefaults
[0])) == (sizeof(aItemInfos
)/sizeof(aItemInfos
[0])));
712 static USHORT pRanges
[] =
714 ITEMID_FONT
,ITEMID_WEIGHT_COMPLEX
,
718 SfxItemPool
* pPool( new SfxItemPool(String::CreateFromAscii("ReportCharProperties"), ITEMID_FONT
,ITEMID_WEIGHT_COMPLEX
, aItemInfos
, pDefaults
) );
719 // not needed for font height pPool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM ); // ripped, don't understand why
720 pPool
->FreezeIdRanges(); // the same
721 bool bSuccess
= false;
724 ::std::auto_ptr
<SfxItemSet
> pDescriptor( new SfxItemSet( *pPool
, pRanges
) );
725 lcl_CharPropertiesToItems( _rxReportControlFormat
, *pDescriptor
);
727 { // want the dialog to be destroyed before our set
728 ORptPageDialog
aDlg(pParent
, pDescriptor
.get(),RID_PAGEDIALOG_CHAR
);
729 uno::Reference
< report::XShape
> xShape( _rxReportControlFormat
, uno::UNO_QUERY
);
731 aDlg
.RemoveTabPage( RID_PAGE_BACKGROUND
);
732 bSuccess
= ( RET_OK
== aDlg
.Execute() );
735 lcl_itemsToCharProperties( lcl_getReportControlFont( _rxReportControlFormat
,WESTERN
),
736 lcl_getReportControlFont( _rxReportControlFormat
,ASIAN
),
737 lcl_getReportControlFont( _rxReportControlFormat
,COMPLEX
), *aDlg
.GetOutputItemSet(), _out_rNewValues
);
741 catch(uno::Exception
&)
743 DBG_UNHANDLED_EXCEPTION();
746 SfxItemPool::Free(pPool
);
747 for (sal_uInt16 i
=0; i
<sizeof(pDefaults
)/sizeof(pDefaults
[0]); ++i
)
752 // -----------------------------------------------------------------------------
753 bool openAreaDialog( const uno::Reference
<report::XShape
>& _xShape
,const uno::Reference
< awt::XWindow
>& _rxParentWindow
)
755 OSL_PRECOND( _xShape
.is() && _rxParentWindow
.is(), "openAreaDialog: invalid parameters!" );
756 if ( !_xShape
.is() || !_rxParentWindow
.is() )
759 ::boost::shared_ptr
<rptui::OReportModel
> pModel
= ::reportdesign::OReportDefinition::getSdrModel(_xShape
->getSection()->getReportDefinition());
761 Window
* pParent
= VCLUnoHelper::GetWindow( _rxParentWindow
);
763 //static USHORT pRanges[] =
765 // XATTR_START,XATTR_END,
769 bool bSuccess
= false;
772 SfxItemPool
& rItemPool
= pModel
->GetItemPool();
773 ::std::auto_ptr
<SfxItemSet
> pDescriptor( new SfxItemSet( rItemPool
, rItemPool
.GetFirstWhich(),rItemPool
.GetLastWhich() ) );
775 lcl_fillShapeToItems(_xShape
,*pDescriptor
);
777 { // want the dialog to be destroyed before our set
778 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
779 ::std::auto_ptr
<AbstractSvxAreaTabDialog
> pDialog(pFact
->CreateSvxAreaTabDialog( pParent
,pDescriptor
.get(),pModel
.get(),RID_SVXDLG_AREA
));
780 // #i74099# by default, the dialog deletes the current color table if a different one is loaded
781 // (see SwDrawShell::ExecDrawDlg)
782 const SvxColorTableItem
* pColorItem
= static_cast<const SvxColorTableItem
*>( pDescriptor
->GetItem(SID_COLOR_TABLE
) );
783 if (pColorItem
&& pColorItem
->GetColorTable() == XColorTable::GetStdColorTable())
784 pDialog
->DontDeleteColorTable();
785 bSuccess
= ( RET_OK
== pDialog
->Execute() );
788 lcl_fillItemsToShape(_xShape
,*pDialog
->GetOutputItemSet());
793 catch(uno::Exception
&)
795 DBG_UNHANDLED_EXCEPTION();
801 // -----------------------------------------------------------------------------
802 void applyCharacterSettings( const uno::Reference
< report::XReportControlFormat
>& _rxReportControlFormat
, const uno::Sequence
< beans::NamedValue
>& _rSettings
)
804 ::comphelper::NamedValueCollection
aSettings( _rSettings
);
808 awt::FontDescriptor aAwtFont
;
809 if ( aSettings
.get( "Font" ) >>= aAwtFont
)
811 ::rtl::OUString sTemp
= aAwtFont
.Name
;
812 aAwtFont
.Name
= ::rtl::OUString(); // hack to
813 _rxReportControlFormat
->setFontDescriptor( aAwtFont
);
814 _rxReportControlFormat
->setCharFontName( sTemp
);
815 } // if ( aSettings.get( "Font" ) >>= aAwtFont )
816 if ( aSettings
.get( "FontAsian" ) >>= aAwtFont
)
818 ::rtl::OUString sTemp
= aAwtFont
.Name
;
819 aAwtFont
.Name
= ::rtl::OUString(); // hack to
820 _rxReportControlFormat
->setFontDescriptorAsian( aAwtFont
);
821 _rxReportControlFormat
->setCharFontNameAsian( sTemp
);
822 } // if ( aSettings.get( "Font" ) >>= aAwtFont )
823 if ( aSettings
.get( "FontComplex" ) >>= aAwtFont
)
825 ::rtl::OUString sTemp
= aAwtFont
.Name
;
826 aAwtFont
.Name
= ::rtl::OUString(); // hack to
827 _rxReportControlFormat
->setFontDescriptorComplex( aAwtFont
);
828 _rxReportControlFormat
->setCharFontNameComplex( sTemp
);
831 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARSHADOWED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharShadowed
);
832 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCONTOURED
, _rxReportControlFormat
, &report::XReportControlFormat::setCharContoured
);
833 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARUNDERLINECOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharUnderlineColor
);
834 lcl_applyFontAttribute( aSettings
, PROPERTY_PARAADJUST
, _rxReportControlFormat
, &report::XReportControlFormat::setParaAdjust
);
835 lcl_applyFontAttribute( aSettings
, PROPERTY_VERTICALALIGN
, _rxReportControlFormat
, &report::XReportControlFormat::setVerticalAlign
);
836 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARRELIEF
, _rxReportControlFormat
, &report::XReportControlFormat::setCharRelief
);
837 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARHIDDEN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharHidden
);
838 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARAUTOKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharAutoKerning
);
839 lcl_applyFontAttribute( aSettings
, PROPERTY_CONTROLBACKGROUND
, _rxReportControlFormat
, &report::XReportControlFormat::setControlBackground
);
840 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARFLASH
, _rxReportControlFormat
, &report::XReportControlFormat::setCharFlash
);
841 lcl_applyFontAttribute( aSettings
, PROPERTY_CHAREMPHASIS
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEmphasis
);
842 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEISON
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineIsOn
);
843 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINEPREFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombinePrefix
);
844 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOMBINESUFFIX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCombineSuffix
);
845 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCOLOR
, _rxReportControlFormat
, &report::XReportControlFormat::setCharColor
);
846 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARKERNING
, _rxReportControlFormat
, &report::XReportControlFormat::setCharKerning
);
847 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARCASEMAP
, _rxReportControlFormat
, &report::XReportControlFormat::setCharCaseMap
);
848 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALE
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocale
);
849 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapement
);
850 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARESCAPEMENTHEIGHT
, _rxReportControlFormat
, &report::XReportControlFormat::setCharEscapementHeight
);
851 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALEASIAN
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleAsian
);
852 lcl_applyFontAttribute( aSettings
, PROPERTY_CHARLOCALECOMPLEX
, _rxReportControlFormat
, &report::XReportControlFormat::setCharLocaleComplex
);
854 catch( const uno::Exception
& )
856 DBG_UNHANDLED_EXCEPTION();
860 // -----------------------------------------------------------------------------
861 void notifySystemWindow(Window
* _pWindow
,Window
* _pToRegister
, ::comphelper::mem_fun1_t
<TaskPaneList
,Window
*> _rMemFunc
)
863 OSL_ENSURE(_pWindow
,"Window can not be null!");
864 SystemWindow
* pSystemWindow
= _pWindow
? _pWindow
->GetSystemWindow() : NULL
;
867 _rMemFunc( pSystemWindow
->GetTaskPaneList(), _pToRegister
);
870 // -----------------------------------------------------------------------------
871 SdrObject
* isOver(const Rectangle
& _rRect
, SdrPage
& _rPage
, SdrView
& _rView
, bool _bAllObjects
, SdrObject
* _pIgnore
, sal_Int16 _nIgnoreType
)
873 SdrObject
* pOverlappedObj
= NULL
;
874 SdrObjListIter
aIter(_rPage
,IM_DEEPNOGROUPS
);
875 SdrObject
* pObjIter
= NULL
;
877 while( !pOverlappedObj
&& (pObjIter
= aIter
.Next()) != NULL
)
879 if ( _pIgnore
!= pObjIter
880 && (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
881 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
883 if (_nIgnoreType
== ISOVER_IGNORE_CUSTOMSHAPES
&& pObjIter
->GetObjIdentifier() == OBJ_CUSTOMSHAPE
)
888 OUnoObject
* pObj
= dynamic_cast<OUnoObject
*>(pObjIter
);
892 Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
893 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
894 pOverlappedObj
= pObjIter
;
898 return pOverlappedObj
;
900 // -----------------------------------------------------------------------------
901 bool checkArrayForOccurance(SdrObject
* _pObjToCheck
, SdrUnoObj
* _pIgnore
[], int _nListLength
)
903 for(int i
=0;i
<_nListLength
;i
++)
905 SdrObject
*pIgnore
= _pIgnore
[i
];
906 if (pIgnore
== _pObjToCheck
)
914 SdrObject
* isOver(const Rectangle
& _rRect
,SdrPage
& _rPage
,SdrView
& _rView
,bool _bAllObjects
, SdrUnoObj
* _pIgnoreList
[], int _nIgnoreListLength
)
916 SdrObject
* pOverlappedObj
= NULL
;
917 SdrObjListIter
aIter(_rPage
,IM_DEEPNOGROUPS
);
918 SdrObject
* pObjIter
= NULL
;
920 while( !pOverlappedObj
&& (pObjIter
= aIter
.Next()) != NULL
)
922 if (checkArrayForOccurance(pObjIter
, _pIgnoreList
, _nIgnoreListLength
))
927 if ( (_bAllObjects
|| !_rView
.IsObjMarked(pObjIter
))
928 && dynamic_cast<OUnoObject
*>(pObjIter
) != NULL
)
930 Rectangle aRect
= _rRect
.GetIntersection(pObjIter
->GetLastBoundRect());
931 if ( !aRect
.IsEmpty() && (aRect
.Left() != aRect
.Right() && aRect
.Top() != aRect
.Bottom() ) )
932 pOverlappedObj
= pObjIter
;
935 return pOverlappedObj
;
938 //----------------------------------------------------------------------------
939 SdrObject
* isOver(SdrObject
* _pObj
,SdrPage
& _rPage
,SdrView
& _rView
,bool _bUnMarkedObjects
)
941 SdrObject
* pOverlappedObj
= NULL
;
942 OUnoObject
* pUnoObj
= dynamic_cast<OUnoObject
*>(_pObj
);
943 if ( pUnoObj
) // this doesn't need to be done for shapes
945 Rectangle aRect
= pUnoObj
->GetCurrentBoundRect();
946 pOverlappedObj
= isOver(aRect
,_rPage
,_rView
,_bUnMarkedObjects
,_pObj
);
948 return pOverlappedObj
;
951 // -----------------------------------------------------------------------------
952 uno::Sequence
< ::rtl::OUString
> getParameterNames( const uno::Reference
< sdbc::XRowSet
>& _rxRowSet
)
954 uno::Sequence
< ::rtl::OUString
> aNames
;
958 uno::Reference
< sdb::XParametersSupplier
> xSuppParams( _rxRowSet
, uno::UNO_QUERY_THROW
);
959 uno::Reference
< container::XIndexAccess
> xParams( xSuppParams
->getParameters() );
962 sal_Int32
count( xParams
->getCount() );
963 aNames
.realloc( count
);
965 uno::Reference
< beans::XPropertySet
> xParam
;
966 ::rtl::OUString sParamName
;
967 for ( sal_Int32 i
=0; i
<count
; ++i
)
969 xParam
.set( xParams
->getByIndex(i
), uno::UNO_QUERY_THROW
);
970 OSL_VERIFY( xParam
->getPropertyValue( PROPERTY_NAME
) >>= sParamName
);
971 aNames
[i
] = sParamName
;
975 catch( const uno::Exception
& )
977 DBG_UNHANDLED_EXCEPTION();
982 // -----------------------------------------------------------------------------
983 Rectangle
getRectangleFromControl(SdrObject
* _pControl
)
987 uno::Reference
< report::XReportComponent
> xComponent( _pControl
->getUnoShape(), uno::UNO_QUERY
);
990 Rectangle
aRect(VCLPoint(xComponent
->getPosition()),VCLSize(xComponent
->getSize()));
991 aRect
.setHeight(aRect
.getHeight() + 1);
992 aRect
.setWidth(aRect
.getWidth() + 1);
998 // -----------------------------------------------------------------------------
1000 void correctOverlapping(SdrObject
* _pControl
,OReportSection
& _aReportSection
,bool _bInsert
)
1002 OSectionView
& rSectionView
= _aReportSection
.getSectionView();
1003 uno::Reference
< report::XReportComponent
> xComponent(_pControl
->getUnoShape(),uno::UNO_QUERY
);
1004 // Rectangle aRet(VCLPoint(xComponent->getPosition()),VCLSize(xComponent->getSize()));
1005 // aRet.setHeight(aRet.getHeight() + 1);
1006 // aRet.setWidth(aRet.getWidth() + 1);
1007 Rectangle aRect
= getRectangleFromControl(_pControl
);
1009 bool bOverlapping
= true;
1010 while ( bOverlapping
)
1012 SdrObject
* pOverlappedObj
= isOver(aRect
,*_aReportSection
.getPage(),rSectionView
,true, _pControl
);
1013 bOverlapping
= pOverlappedObj
!= NULL
;
1016 const Rectangle
& aLogicRect
= pOverlappedObj
->GetLogicRect();
1017 aRect
.Move(0,aLogicRect
.Top() + aLogicRect
.getHeight() - aRect
.Top());
1018 xComponent
->setPositionY(aRect
.Top());
1021 if ( !bOverlapping
&& _bInsert
) // now insert objects
1022 rSectionView
.InsertObjectAtView(_pControl
,*rSectionView
.GetSdrPageView(),SDRINSERT_ADDMARK
);
1024 // -----------------------------------------------------------------------------
1025 void setZoomFactor(const Fraction
& _aZoom
,Window
& _rWindow
)
1027 MapMode
aMapMode( _rWindow
.GetMapMode() );
1028 aMapMode
.SetScaleX(_aZoom
);
1029 aMapMode
.SetScaleY(_aZoom
);
1030 _rWindow
.SetMapMode(aMapMode
);
1032 // -----------------------------------------------------------------------------
1033 bool openDialogFormula_nothrow( ::rtl::OUString
& _in_out_rFormula
1034 , const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _xContext
1035 , const uno::Reference
< awt::XWindow
>& _xInspectorWindow
1036 , const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _xRowSet
1039 OSL_PRECOND( _xInspectorWindow
.is(), "openDialogFormula_nothrow: invalid parameters!" );
1040 if ( !_xInspectorWindow
.is() )
1042 // _out_rFormula = ::rtl::OUString();
1043 bool bSuccess
= false;
1044 ::dbtools::SQLExceptionInfo aErrorInfo
;
1045 uno::Reference
< awt::XWindow
> xInspectorWindow
;
1046 uno::Reference
< lang::XMultiComponentFactory
> xFactory
;
1047 uno::Reference
<lang::XMultiServiceFactory
> xServiceFactory
;
1050 xFactory
= _xContext
->getServiceManager();
1051 xServiceFactory
.set(xFactory
,uno::UNO_QUERY
);
1052 Window
* pParent
= VCLUnoHelper::GetWindow( _xInspectorWindow
);
1054 uno::Reference
< report::meta::XFunctionManager
> xMgr(xFactory
->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOFunctionManager")),_xContext
),uno::UNO_QUERY
);
1057 ::boost::shared_ptr
< formula::IFunctionManager
> pFormulaManager(new FunctionManager(xMgr
) );
1058 ReportFormula
aFormula( _in_out_rFormula
);
1059 FormulaDialog
aDlg(pParent
,xServiceFactory
,pFormulaManager
,aFormula
.getUndecoratedContent(),_xRowSet
);
1060 bSuccess
= aDlg
.Execute() == RET_OK
;
1063 String sFormula
= aDlg
.getCurrentFormula();
1064 xub_StrLen nIndex
= 0;
1065 if ( sFormula
.GetChar(0) == '=' )
1067 _in_out_rFormula
= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rpt:")) + sFormula
.Copy(nIndex
);
1071 catch (sdb::SQLContext
& e
) { aErrorInfo
= e
; }
1072 catch (sdbc::SQLWarning
& e
) { aErrorInfo
= e
; }
1073 catch (sdbc::SQLException
& e
) { aErrorInfo
= e
; }
1074 catch( const uno::Exception
& )
1076 OSL_ENSURE( sal_False
, "GeometryHandler::impl_dialogFilter_nothrow: caught an exception!" );
1079 if ( aErrorInfo
.isValid() )
1080 ::dbtools::showError( aErrorInfo
, xInspectorWindow
, xServiceFactory
);
1084 // -----------------------------------------------------------------------------
1085 } // namespace rptui
1086 // -----------------------------------------------------------------------------