bump product version to 7.6.3.2-android
[LibreOffice.git] / reportdesign / source / core / api / FixedLine.cxx
blobf20561b8b5673586809eef0871e201aaa5a9887a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <FixedLine.hxx>
20 #include <strings.hxx>
21 #include <strings.hrc>
22 #include <core_resource.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <comphelper/diagnose_ex.hxx>
25 #include <Tools.hxx>
26 #include <FormatCondition.hxx>
27 #include <ReportHelperImpl.hxx>
29 #define MIN_WIDTH 80
30 #define MIN_HEIGHT 20
32 namespace reportdesign
35 using namespace com::sun::star;
36 static uno::Sequence< OUString > lcl_getLineOptionals()
38 OUString pProps[] = {
39 OUString(PROPERTY_DATAFIELD)
40 ,OUString(PROPERTY_DEFAULTCONTROL)
41 ,OUString(PROPERTY_CONTROLBORDER)
42 ,OUString(PROPERTY_CONTROLBORDERCOLOR)
43 ,OUString(PROPERTY_CHARCOLOR)
44 ,OUString(PROPERTY_CHAREMPHASIS)
45 ,OUString(PROPERTY_CHARFONTCHARSET)
46 ,OUString(PROPERTY_CHARFONTFAMILY)
47 ,OUString(PROPERTY_CHARFONTNAME)
48 ,OUString(PROPERTY_CHARFONTPITCH)
49 ,OUString(PROPERTY_CHARFONTSTYLENAME)
50 ,OUString(PROPERTY_CHARHEIGHT)
51 ,OUString(PROPERTY_CHARPOSTURE)
52 ,OUString(PROPERTY_CHARRELIEF)
53 ,OUString(PROPERTY_FONTDESCRIPTOR)
54 ,OUString(PROPERTY_FONTDESCRIPTORASIAN)
55 ,OUString(PROPERTY_FONTDESCRIPTORCOMPLEX)
56 ,OUString(PROPERTY_CONTROLTEXTEMPHASISMARK)
57 ,OUString(PROPERTY_CHARROTATION)
58 ,OUString(PROPERTY_CHARSCALEWIDTH)
59 ,OUString(PROPERTY_CHARSTRIKEOUT)
60 ,OUString(PROPERTY_CHARUNDERLINECOLOR)
61 ,OUString(PROPERTY_CHARUNDERLINE)
62 ,OUString(PROPERTY_CHARWEIGHT)
63 ,OUString(PROPERTY_CHARWORDMODE)
64 ,OUString(PROPERTY_CONTROLBACKGROUND)
65 ,OUString(PROPERTY_CONTROLBACKGROUNDTRANSPARENT)
66 ,OUString(PROPERTY_CHARFLASH)
67 ,OUString(PROPERTY_CHARAUTOKERNING)
68 ,OUString(PROPERTY_CHARESCAPEMENTHEIGHT)
69 ,OUString(PROPERTY_CHARLOCALE)
70 ,OUString(PROPERTY_CHARESCAPEMENT)
71 ,OUString(PROPERTY_CHARCASEMAP)
72 ,OUString(PROPERTY_CHARCOMBINEISON)
73 ,OUString(PROPERTY_CHARCOMBINEPREFIX)
74 ,OUString(PROPERTY_CHARCOMBINESUFFIX)
75 ,OUString(PROPERTY_CHARHIDDEN)
76 ,OUString(PROPERTY_CHARSHADOWED)
77 ,OUString(PROPERTY_CHARCONTOURED)
78 ,OUString(PROPERTY_HYPERLINKURL)
79 ,OUString(PROPERTY_HYPERLINKTARGET)
80 ,OUString(PROPERTY_HYPERLINKNAME)
81 ,OUString(PROPERTY_VISITEDCHARSTYLENAME)
82 ,OUString(PROPERTY_UNVISITEDCHARSTYLENAME)
83 ,OUString(PROPERTY_CHARKERNING)
84 ,OUString(PROPERTY_PRINTREPEATEDVALUES)
85 ,OUString(PROPERTY_CONDITIONALPRINTEXPRESSION)
86 ,OUString(PROPERTY_PRINTWHENGROUPCHANGE)
87 ,OUString(PROPERTY_MASTERFIELDS)
88 ,OUString(PROPERTY_DETAILFIELDS)
89 ,OUString(PROPERTY_PARAADJUST)
91 , OUString(PROPERTY_CHAREMPHASISASIAN)
92 , OUString(PROPERTY_CHARFONTNAMEASIAN)
93 , OUString(PROPERTY_CHARFONTSTYLENAMEASIAN)
94 , OUString(PROPERTY_CHARFONTFAMILYASIAN)
95 , OUString(PROPERTY_CHARFONTCHARSETASIAN)
96 , OUString(PROPERTY_CHARFONTPITCHASIAN)
97 , OUString(PROPERTY_CHARHEIGHTASIAN)
98 , OUString(PROPERTY_CHARUNDERLINEASIAN)
99 , OUString(PROPERTY_CHARWEIGHTASIAN)
100 , OUString(PROPERTY_CHARPOSTUREASIAN)
101 , OUString(PROPERTY_CHARWORDMODEASIAN)
102 , OUString(PROPERTY_CHARROTATIONASIAN)
103 , OUString(PROPERTY_CHARSCALEWIDTHASIAN)
104 , OUString(PROPERTY_CHARLOCALEASIAN)
105 , OUString(PROPERTY_CHAREMPHASISCOMPLEX)
106 , OUString(PROPERTY_CHARFONTNAMECOMPLEX)
107 , OUString(PROPERTY_CHARFONTSTYLENAMECOMPLEX)
108 , OUString(PROPERTY_CHARFONTFAMILYCOMPLEX)
109 , OUString(PROPERTY_CHARFONTCHARSETCOMPLEX)
110 , OUString(PROPERTY_CHARFONTPITCHCOMPLEX)
111 , OUString(PROPERTY_CHARHEIGHTCOMPLEX)
112 , OUString(PROPERTY_CHARUNDERLINECOMPLEX)
113 , OUString(PROPERTY_CHARWEIGHTCOMPLEX)
114 , OUString(PROPERTY_CHARPOSTURECOMPLEX)
115 , OUString(PROPERTY_CHARWORDMODECOMPLEX)
116 , OUString(PROPERTY_CHARROTATIONCOMPLEX)
117 , OUString(PROPERTY_CHARSCALEWIDTHCOMPLEX)
118 , OUString(PROPERTY_CHARLOCALECOMPLEX)
122 return uno::Sequence< OUString >(pProps,SAL_N_ELEMENTS(pProps));
125 OFixedLine::OFixedLine(uno::Reference< uno::XComponentContext > const & _xContext)
126 :FixedLineBase(m_aMutex)
127 ,FixedLinePropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getLineOptionals())
128 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
129 ,m_LineStyle( drawing::LineStyle_NONE )
130 ,m_nOrientation(1)
131 ,m_LineColor(0)
132 ,m_LineTransparence(0)
133 ,m_LineWidth(0)
135 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDLINE);
136 m_aProps.aComponent.m_nWidth = MIN_WIDTH;
139 OFixedLine::OFixedLine(uno::Reference< uno::XComponentContext > const & _xContext
140 ,const uno::Reference< lang::XMultiServiceFactory>& _xFactory
141 ,uno::Reference< drawing::XShape >& _xShape
142 ,sal_Int32 _nOrientation)
143 :FixedLineBase(m_aMutex)
144 ,FixedLinePropertySet(_xContext,IMPLEMENTS_PROPERTY_SET,lcl_getLineOptionals())
145 ,m_aProps(m_aMutex,static_cast< container::XContainer*>( this ),_xContext)
146 ,m_LineStyle( drawing::LineStyle_NONE )
147 ,m_nOrientation(_nOrientation)
148 ,m_LineColor(0)
149 ,m_LineTransparence(0)
150 ,m_LineWidth(0)
152 m_aProps.aComponent.m_sName = RptResId(RID_STR_FIXEDLINE);
153 m_aProps.aComponent.m_xFactory = _xFactory;
154 osl_atomic_increment( &m_refCount );
157 awt::Size aSize = _xShape->getSize();
158 if ( m_nOrientation == 1 )
160 if ( aSize.Width < MIN_WIDTH )
162 aSize.Width = MIN_WIDTH;
163 _xShape->setSize(aSize);
166 else if ( MIN_HEIGHT > aSize.Height )
168 aSize.Height = MIN_HEIGHT;
169 _xShape->setSize(aSize);
171 m_aProps.aComponent.setShape(_xShape,this,m_refCount);
173 catch(uno::Exception&)
175 TOOLS_WARN_EXCEPTION( "reportdesign", "OFixedLine::OFixedLine");
177 osl_atomic_decrement( &m_refCount );
180 OFixedLine::~OFixedLine()
184 IMPLEMENT_FORWARD_REFCOUNT( OFixedLine, FixedLineBase )
186 uno::Any SAL_CALL OFixedLine::queryInterface( const uno::Type& _rType )
188 uno::Any aReturn = FixedLineBase::queryInterface(_rType);
189 if ( !aReturn.hasValue() )
190 aReturn = FixedLinePropertySet::queryInterface(_rType);
191 if ( !aReturn.hasValue() && OReportControlModel::isInterfaceForbidden(_rType) )
192 return aReturn;
194 return aReturn.hasValue() ? aReturn : (m_aProps.aComponent.m_xProxy.is() ? m_aProps.aComponent.m_xProxy->queryAggregation(_rType) : aReturn);
197 void SAL_CALL OFixedLine::dispose()
199 FixedLinePropertySet::dispose();
200 cppu::WeakComponentImplHelperBase::dispose();
203 OUString OFixedLine::getImplementationName_Static( )
205 return "com.sun.star.comp.report.OFixedLine";
209 OUString SAL_CALL OFixedLine::getImplementationName( )
211 return getImplementationName_Static();
214 uno::Sequence< OUString > OFixedLine::getSupportedServiceNames_Static( )
216 uno::Sequence< OUString > aServices { SERVICE_FIXEDLINE };
218 return aServices;
221 uno::Reference< uno::XInterface > OFixedLine::create(uno::Reference< uno::XComponentContext > const & xContext)
223 return *(new OFixedLine(xContext));
227 uno::Sequence< OUString > SAL_CALL OFixedLine::getSupportedServiceNames( )
229 return getSupportedServiceNames_Static();
232 sal_Bool SAL_CALL OFixedLine::supportsService(const OUString& ServiceName)
234 return cppu::supportsService(this, ServiceName);
237 // XReportComponent
238 REPORTCOMPONENT_IMPL3(OFixedLine,m_aProps.aComponent)
239 REPORTCOMPONENT_NOMASTERDETAIL(OFixedLine)
241 ::sal_Int16 SAL_CALL OFixedLine::getControlBorder( )
243 throw beans::UnknownPropertyException();
246 void SAL_CALL OFixedLine::setControlBorder( ::sal_Int16 /*_border*/ )
248 throw beans::UnknownPropertyException();
251 ::sal_Int32 SAL_CALL OFixedLine::getControlBorderColor()
253 throw beans::UnknownPropertyException();
256 void SAL_CALL OFixedLine::setControlBorderColor( ::sal_Int32 /*_bordercolor*/ )
258 throw beans::UnknownPropertyException();
261 uno::Reference< beans::XPropertySetInfo > SAL_CALL OFixedLine::getPropertySetInfo( )
263 return FixedLinePropertySet::getPropertySetInfo();
266 void SAL_CALL OFixedLine::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
268 FixedLinePropertySet::setPropertyValue( aPropertyName, aValue );
271 uno::Any SAL_CALL OFixedLine::getPropertyValue( const OUString& PropertyName )
273 return FixedLinePropertySet::getPropertyValue( PropertyName);
276 void SAL_CALL OFixedLine::addPropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& xListener )
278 FixedLinePropertySet::addPropertyChangeListener( aPropertyName, xListener );
281 void SAL_CALL OFixedLine::removePropertyChangeListener( const OUString& aPropertyName, const uno::Reference< beans::XPropertyChangeListener >& aListener )
283 FixedLinePropertySet::removePropertyChangeListener( aPropertyName, aListener );
286 void SAL_CALL OFixedLine::addVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
288 FixedLinePropertySet::addVetoableChangeListener( PropertyName, aListener );
291 void SAL_CALL OFixedLine::removeVetoableChangeListener( const OUString& PropertyName, const uno::Reference< beans::XVetoableChangeListener >& aListener )
293 FixedLinePropertySet::removeVetoableChangeListener( PropertyName, aListener );
296 // XReportControlModel
297 OUString SAL_CALL OFixedLine::getDataField()
299 throw beans::UnknownPropertyException();
302 void SAL_CALL OFixedLine::setDataField( const OUString& /*_datafield*/ )
304 throw beans::UnknownPropertyException();
307 ::sal_Int32 SAL_CALL OFixedLine::getControlBackground()
309 throw beans::UnknownPropertyException();
312 void SAL_CALL OFixedLine::setControlBackground( ::sal_Int32 /*_backgroundcolor*/ )
314 throw beans::UnknownPropertyException();
317 sal_Bool SAL_CALL OFixedLine::getControlBackgroundTransparent()
319 throw beans::UnknownPropertyException();
322 void SAL_CALL OFixedLine::setControlBackgroundTransparent( sal_Bool /*_controlbackgroundtransparent*/ )
324 throw beans::UnknownPropertyException();
327 sal_Bool SAL_CALL OFixedLine::getPrintWhenGroupChange()
329 throw beans::UnknownPropertyException();
332 void SAL_CALL OFixedLine::setPrintWhenGroupChange( sal_Bool /*_printwhengroupchange*/ )
334 throw beans::UnknownPropertyException();
337 OUString SAL_CALL OFixedLine::getConditionalPrintExpression()
339 throw beans::UnknownPropertyException();
342 void SAL_CALL OFixedLine::setConditionalPrintExpression( const OUString& /*_conditionalprintexpression*/ )
344 throw beans::UnknownPropertyException();
347 // XCloneable
348 uno::Reference< util::XCloneable > SAL_CALL OFixedLine::createClone( )
350 uno::Reference< report::XReportComponent> xSource = this;
351 uno::Reference< report::XFixedLine> xSet(cloneObject(xSource,m_aProps.aComponent.m_xFactory,SERVICE_FIXEDLINE),uno::UNO_QUERY_THROW);
352 return xSet;
356 // XFixedLine
358 ::sal_Int32 SAL_CALL OFixedLine::getOrientation()
360 ::osl::MutexGuard aGuard(m_aMutex);
361 return m_nOrientation;
364 void SAL_CALL OFixedLine::setOrientation( ::sal_Int32 _orientation )
366 set(PROPERTY_ORIENTATION,_orientation,m_nOrientation);
369 drawing::LineStyle SAL_CALL OFixedLine::getLineStyle()
371 ::osl::MutexGuard aGuard(m_aMutex);
372 return m_LineStyle;
375 void SAL_CALL OFixedLine::setLineStyle( drawing::LineStyle _linestyle )
377 set(PROPERTY_LINESTYLE,_linestyle,m_LineStyle);
380 drawing::LineDash SAL_CALL OFixedLine::getLineDash()
382 ::osl::MutexGuard aGuard(m_aMutex);
383 return m_LineDash;
386 void SAL_CALL OFixedLine::setLineDash( const drawing::LineDash& _linedash )
388 set(PROPERTY_LINEDASH,_linedash,m_LineDash);
391 ::sal_Int32 SAL_CALL OFixedLine::getLineColor()
393 ::osl::MutexGuard aGuard(m_aMutex);
394 return m_LineColor;
397 void SAL_CALL OFixedLine::setLineColor( ::sal_Int32 _linecolor )
399 set(PROPERTY_LINECOLOR,_linecolor,m_LineColor);
402 ::sal_Int16 SAL_CALL OFixedLine::getLineTransparence()
404 ::osl::MutexGuard aGuard(m_aMutex);
405 return m_LineTransparence;
408 void SAL_CALL OFixedLine::setLineTransparence( ::sal_Int16 _linetransparence )
410 set(PROPERTY_LINETRANSPARENCE,_linetransparence,m_LineTransparence);
413 ::sal_Int32 SAL_CALL OFixedLine::getLineWidth()
415 ::osl::MutexGuard aGuard(m_aMutex);
416 return m_LineWidth;
419 void SAL_CALL OFixedLine::setLineWidth( ::sal_Int32 _linewidth )
421 set(PROPERTY_LINEWIDTH,_linewidth,m_LineWidth);
425 // XChild
426 uno::Reference< uno::XInterface > SAL_CALL OFixedLine::getParent( )
428 return OShapeHelper::getParent(this);
431 void SAL_CALL OFixedLine::setParent( const uno::Reference< uno::XInterface >& Parent )
433 OShapeHelper::setParent(Parent,this);
436 uno::Reference< report::XFormatCondition > SAL_CALL OFixedLine::createFormatCondition( )
438 return new OFormatCondition(m_aProps.aComponent.m_xContext);
441 // XContainer
442 void SAL_CALL OFixedLine::addContainerListener( const uno::Reference< container::XContainerListener >& xListener )
444 m_aProps.addContainerListener(xListener);
447 void SAL_CALL OFixedLine::removeContainerListener( const uno::Reference< container::XContainerListener >& xListener )
449 m_aProps.removeContainerListener(xListener);
452 // XElementAccess
453 uno::Type SAL_CALL OFixedLine::getElementType( )
455 return cppu::UnoType<report::XFormatCondition>::get();
458 sal_Bool SAL_CALL OFixedLine::hasElements( )
460 return m_aProps.hasElements();
463 // XIndexContainer
464 void SAL_CALL OFixedLine::insertByIndex( ::sal_Int32 Index, const uno::Any& Element )
466 m_aProps.insertByIndex(Index,Element);
469 void SAL_CALL OFixedLine::removeByIndex( ::sal_Int32 Index )
471 m_aProps.removeByIndex(Index);
474 // XIndexReplace
475 void SAL_CALL OFixedLine::replaceByIndex( ::sal_Int32 Index, const uno::Any& Element )
477 m_aProps.replaceByIndex(Index,Element);
480 // XIndexAccess
481 ::sal_Int32 SAL_CALL OFixedLine::getCount( )
483 return m_aProps.getCount();
486 uno::Any SAL_CALL OFixedLine::getByIndex( ::sal_Int32 Index )
488 return m_aProps.getByIndex( Index );
491 // XShape
492 awt::Point SAL_CALL OFixedLine::getPosition( )
494 return OShapeHelper::getPosition(this);
497 void SAL_CALL OFixedLine::setPosition( const awt::Point& aPosition )
499 OShapeHelper::setPosition(aPosition,this);
502 awt::Size SAL_CALL OFixedLine::getSize( )
504 return OShapeHelper::getSize(this);
507 void SAL_CALL OFixedLine::setSize( const awt::Size& aSize )
509 if ( aSize.Width < MIN_WIDTH && m_nOrientation == 1 )
510 throw beans::PropertyVetoException("Too small width for FixedLine; minimum is " + OUString::number(MIN_WIDTH) + "0 micrometer", getXWeak());
511 else if ( aSize.Height < MIN_HEIGHT && m_nOrientation == 0 )
512 throw beans::PropertyVetoException("Too small height for FixedLine; minimum is " + OUString::number(MIN_HEIGHT) + "0 micrometer", getXWeak());
513 OShapeHelper::setSize(aSize,this);
516 // XShapeDescriptor
517 OUString SAL_CALL OFixedLine::getShapeType( )
519 ::osl::MutexGuard aGuard(m_aMutex);
520 if ( m_aProps.aComponent.m_xShape.is() )
521 return m_aProps.aComponent.m_xShape->getShapeType();
522 return "com.sun.star.drawing.ControlShape";
525 OUString SAL_CALL OFixedLine::getHyperLinkURL()
527 throw beans::UnknownPropertyException();
529 void SAL_CALL OFixedLine::setHyperLinkURL(const OUString & /*the_value*/)
531 throw beans::UnknownPropertyException();
533 OUString SAL_CALL OFixedLine::getHyperLinkTarget()
535 throw beans::UnknownPropertyException();
537 void SAL_CALL OFixedLine::setHyperLinkTarget(const OUString & /*the_value*/)
539 throw beans::UnknownPropertyException();
541 OUString SAL_CALL OFixedLine::getHyperLinkName()
543 throw beans::UnknownPropertyException();
545 void SAL_CALL OFixedLine::setHyperLinkName(const OUString & /*the_value*/)
547 throw beans::UnknownPropertyException();
550 NO_REPORTCONTROLFORMAT_IMPL(OFixedLine)
552 sal_Bool SAL_CALL OFixedLine::getPrintRepeatedValues()
554 throw beans::UnknownPropertyException();
556 void SAL_CALL OFixedLine::setPrintRepeatedValues( sal_Bool /*_printrepeatedvalues*/ )
558 throw beans::UnknownPropertyException();
562 } // namespace reportdesign
565 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */