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