LibreOffice Module svx (master)  1
XPropertyTable.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include <memory>
22 #include <XPropertyTable.hxx>
23 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
24 #include <com/sun/star/drawing/LineDash.hpp>
25 #include <com/sun/star/awt/Gradient.hpp>
26 #include <com/sun/star/awt/XBitmap.hpp>
27 #include <com/sun/star/graphic/XGraphic.hpp>
28 #include <com/sun/star/drawing/Hatch.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <o3tl/any.hxx>
32 #include <vcl/svapp.hxx>
33 
34 #include <cppuhelper/implbase.hxx>
36 #include <svx/xdef.hxx>
37 
38 #include <svx/unoapi.hxx>
40 
41 using namespace com::sun::star;
42 using namespace ::cppu;
43 
44 namespace {
45 
46 class SvxUnoXPropertyTable : public WeakImplHelper< container::XNameContainer, lang::XServiceInfo >
47 {
48 private:
50  sal_Int16 mnWhich;
51 
52  long getCount() const { return mpList ? mpList->Count() : 0; }
53  const XPropertyEntry* get(long index) const;
54 public:
55  SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
56 
58  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const = 0;
61  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const = 0;
62 
63  // XServiceInfo
64  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
65 
66  // XNameContainer
67  virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) override;
68  virtual void SAL_CALL removeByName( const OUString& Name ) override;
69 
70  // XNameReplace
71  virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override;
72 
73  // XNameAccess
74  virtual uno::Any SAL_CALL getByName( const OUString& aName ) override;
75  virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override;
76  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
77 
78  // XElementAccess
79  virtual sal_Bool SAL_CALL hasElements( ) override;
80 };
81 
82 }
83 
84 SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
85 : mpList( pList ), mnWhich( nWhich )
86 {
87 }
88 
89 const XPropertyEntry* SvxUnoXPropertyTable::get(long index) const
90 {
91  if( mpList )
92  return mpList->Get(index);
93  else
94  return nullptr;
95 }
96 
97 // XServiceInfo
98 sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
99 {
100  return cppu::supportsService(this, ServiceName);
101 }
102 
103 // XNameContainer
104 void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
105 {
106  SolarMutexGuard aGuard;
107 
108  if( nullptr == mpList )
109  throw lang::IllegalArgumentException();
110 
111  if( hasByName( aName ) )
112  throw container::ElementExistException();
113 
114  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
115 
116  std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
117  if (!pNewEntry)
118  throw lang::IllegalArgumentException();
119 
120  mpList->Insert(std::move(pNewEntry));
121 }
122 
123 void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
124 {
125  SolarMutexGuard aGuard;
126 
127  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, Name);
128 
129  const long nCount = getCount();
130  long i;
131  for( i = 0; i < nCount; i++ )
132  {
133  const XPropertyEntry* pEntry = get(i);
134  if (pEntry && aInternalName == pEntry->GetName())
135  {
136  mpList->Remove(i);
137  return;
138  }
139  }
140 
141  throw container::NoSuchElementException();
142 }
143 
144 // XNameReplace
145 void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
146 {
147  SolarMutexGuard aGuard;
148 
149  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
150 
151  const long nCount = getCount();
152  long i;
153  for( i = 0; i < nCount; i++ )
154  {
155  const XPropertyEntry* pEntry = get(i);
156  if (pEntry && aInternalName == pEntry->GetName())
157  {
158  std::unique_ptr<XPropertyEntry> pNewEntry(createEntry(aInternalName, aElement));
159  if (!pNewEntry)
160  throw lang::IllegalArgumentException();
161 
162  mpList->Replace(std::move(pNewEntry), i);
163  return;
164  }
165  }
166 
167  throw container::NoSuchElementException();
168 }
169 
170 // XNameAccess
171 uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
172 {
173  SolarMutexGuard aGuard;
174 
175  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
176 
177  const long nCount = getCount();
178  long i;
179  for( i = 0; i < nCount; i++ )
180  {
181  const XPropertyEntry* pEntry = get(i);
182 
183  if (pEntry && aInternalName == pEntry->GetName())
184  return getAny( pEntry );
185  }
186 
187  throw container::NoSuchElementException();
188 }
189 
190 uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
191 {
192  SolarMutexGuard aGuard;
193 
194  const long nCount = getCount();
195  uno::Sequence< OUString > aNames( nCount );
196  OUString* pNames = aNames.getArray();
197  long i;
198  for( i = 0; i < nCount; i++ )
199  {
200  const XPropertyEntry* pEntry = get(i);
201 
202  if (pEntry)
203  *pNames++ = SvxUnogetApiNameForItem(mnWhich, pEntry->GetName());
204  }
205 
206  return aNames;
207 }
208 
209 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
210 {
211  SolarMutexGuard aGuard;
212 
213  OUString aInternalName = SvxUnogetInternalNameForItem(mnWhich, aName);
214 
215  const long nCount = mpList?mpList->Count():0;
216  long i;
217  for( i = 0; i < nCount; i++ )
218  {
219  const XPropertyEntry* pEntry = get(i);
220  if (pEntry && aInternalName == pEntry->GetName())
221  return true;
222  }
223 
224  return false;
225 }
226 
227 // XElementAccess
228 sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
229 {
230  SolarMutexGuard aGuard;
231 
232  return getCount() != 0;
233 }
234 
235 namespace {
236 
237 class SvxUnoXColorTable : public SvxUnoXPropertyTable
238 {
239 public:
240  explicit SvxUnoXColorTable( XPropertyList* pList ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pList ) {};
241 
242  // SvxUnoXPropertyTable
243  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
244  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
245 
246  // XElementAccess
247  virtual uno::Type SAL_CALL getElementType() override;
248 
249  // XServiceInfo
250  virtual OUString SAL_CALL getImplementationName( ) override;
251  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
252 };
253 
254 }
255 
256 uno::Reference< uno::XInterface > SvxUnoXColorTable_createInstance( XPropertyList* pList ) throw()
257 {
258  return static_cast<OWeakObject*>(new SvxUnoXColorTable( pList ));
259 }
260 
261 // SvxUnoXPropertyTable
262 uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
263 {
264  return uno::Any( static_cast<sal_Int32>(static_cast<const XColorEntry*>(pEntry)->GetColor()) );
265 }
266 
267 std::unique_ptr<XPropertyEntry> SvxUnoXColorTable::createEntry(const OUString& rName, const uno::Any& rAny) const
268 {
269  Color aColor;
270  if( !(rAny >>= aColor) )
271  return std::unique_ptr<XPropertyEntry>();
272 
273  return std::make_unique<XColorEntry>(aColor, rName);
274 }
275 
276 // XElementAccess
277 uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
278 {
279  return ::cppu::UnoType<sal_Int32>::get();
280 }
281 
282 // XServiceInfo
283 OUString SAL_CALL SvxUnoXColorTable::getImplementationName( )
284 {
285  return "SvxUnoXColorTable";
286 }
287 
288 uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( )
289 {
290  return { "com.sun.star.drawing.ColorTable" };
291 }
292 
293 namespace {
294 
295 class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
296 {
297 public:
298  explicit SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
299 
300  // SvxUnoXPropertyTable
301  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
302  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
303 
304  // XElementAccess
305  virtual uno::Type SAL_CALL getElementType() override;
306 
307  // XServiceInfo
308  virtual OUString SAL_CALL getImplementationName( ) override;
309  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
310 };
311 
312 }
313 
314 uno::Reference< uno::XInterface > SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
315 {
316  return static_cast<OWeakObject*>(new SvxUnoXLineEndTable( pTable ));
317 }
318 
319 // SvxUnoXPropertyTable
320 uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
321 {
322  drawing::PolyPolygonBezierCoords aBezier;
323  basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( static_cast<const XLineEndEntry*>(pEntry)->GetLineEnd(),
324  aBezier );
325  return uno::Any(aBezier);
326 }
327 
328 std::unique_ptr<XPropertyEntry> SvxUnoXLineEndTable::createEntry(const OUString& rName, const uno::Any& rAny) const
329 {
330  auto pCoords = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rAny);
331  if( !pCoords )
332  return std::unique_ptr<XLineEndEntry>();
333 
334  basegfx::B2DPolyPolygon aPolyPolygon;
335  if( pCoords->Coordinates.getLength() > 0 )
337 
338  // #86265# make sure polygon is closed
339  aPolyPolygon.setClosed(true);
340 
341  return std::make_unique<XLineEndEntry>(aPolyPolygon, rName);
342 }
343 
344 // XElementAccess
345 uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
346 {
348 }
349 
350 // XServiceInfo
351 OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( )
352 {
353  return "SvxUnoXLineEndTable";
354 }
355 
356 uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( )
357 {
358  return { "com.sun.star.drawing.LineEndTable" };
359 }
360 
361 namespace {
362 
363 class SvxUnoXDashTable : public SvxUnoXPropertyTable
364 {
365 public:
366  explicit SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
367 
368  // SvxUnoXPropertyTable
369  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
370  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
371 
372  // XElementAccess
373  virtual uno::Type SAL_CALL getElementType() override;
374 
375  // XServiceInfo
376  virtual OUString SAL_CALL getImplementationName( ) override;
377  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
378 };
379 
380 }
381 
382 uno::Reference< uno::XInterface > SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
383 {
384  return static_cast<OWeakObject*>(new SvxUnoXDashTable( pTable ));
385 }
386 
387 // SvxUnoXPropertyTable
388 uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
389 {
390  const XDash& rXD = static_cast<const XDashEntry*>(pEntry)->GetDash();
391 
392  drawing::LineDash aLineDash;
393 
394  aLineDash.Style = static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(rXD.GetDashStyle()));
395  aLineDash.Dots = rXD.GetDots();
396  aLineDash.DotLen = rXD.GetDotLen();
397  aLineDash.Dashes = rXD.GetDashes();
398  aLineDash.DashLen = rXD.GetDashLen();
399  aLineDash.Distance = rXD.GetDistance();
400 
401  return uno::Any(aLineDash);
402 }
403 
404 std::unique_ptr<XPropertyEntry> SvxUnoXDashTable::createEntry(const OUString& rName, const uno::Any& rAny) const
405 {
406  drawing::LineDash aLineDash;
407  if(!(rAny >>= aLineDash))
408  return std::unique_ptr<XDashEntry>();
409 
410  XDash aXDash;
411 
412  aXDash.SetDashStyle(static_cast<css::drawing::DashStyle>(static_cast<sal_uInt16>(aLineDash.Style)));
413  aXDash.SetDots(aLineDash.Dots);
414  aXDash.SetDotLen(aLineDash.DotLen);
415  aXDash.SetDashes(aLineDash.Dashes);
416  aXDash.SetDashLen(aLineDash.DashLen);
417  aXDash.SetDistance(aLineDash.Distance);
418 
419  return std::make_unique<XDashEntry>(aXDash, rName);
420 }
421 
422 // XElementAccess
423 uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
424 {
426 }
427 
428 // XServiceInfo
429 OUString SAL_CALL SvxUnoXDashTable::getImplementationName( )
430 {
431  return "SvxUnoXDashTable";
432 }
433 
434 uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( )
435 {
436  return { "com.sun.star.drawing.DashTable" };
437 }
438 
439 namespace {
440 
441 class SvxUnoXHatchTable : public SvxUnoXPropertyTable
442 {
443 public:
444  explicit SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
445 
446  // SvxUnoXPropertyTable
447  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
448  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
449 
450  // XElementAccess
451  virtual uno::Type SAL_CALL getElementType() override;
452 
453  // XServiceInfo
454  virtual OUString SAL_CALL getImplementationName( ) override;
455  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
456 };
457 
458 }
459 
460 uno::Reference< uno::XInterface > SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
461 {
462  return static_cast<OWeakObject*>(new SvxUnoXHatchTable( pTable ));
463 }
464 
465 // SvxUnoXPropertyTable
466 uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
467 {
468  const XHatch& aHatch = static_cast<const XHatchEntry*>(pEntry)->GetHatch();
469 
470  drawing::Hatch aUnoHatch;
471 
472  aUnoHatch.Style = aHatch.GetHatchStyle();
473  aUnoHatch.Color = sal_Int32(aHatch.GetColor());
474  aUnoHatch.Distance = aHatch.GetDistance();
475  aUnoHatch.Angle = aHatch.GetAngle();
476 
477  return uno::Any(aUnoHatch);
478 }
479 
480 std::unique_ptr<XPropertyEntry> SvxUnoXHatchTable::createEntry(const OUString& rName, const uno::Any& rAny) const
481 {
482  drawing::Hatch aUnoHatch;
483  if(!(rAny >>= aUnoHatch))
484  return std::unique_ptr<XHatchEntry>();
485 
486  XHatch aXHatch;
487  aXHatch.SetHatchStyle( aUnoHatch.Style );
488  aXHatch.SetColor( Color(aUnoHatch.Color) );
489  aXHatch.SetDistance( aUnoHatch.Distance );
490  aXHatch.SetAngle( aUnoHatch.Angle );
491 
492  return std::make_unique<XHatchEntry>(aXHatch, rName);
493 }
494 
495 // XElementAccess
496 uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
497 {
499 }
500 
501 // XServiceInfo
502 OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( )
503 {
504  return "SvxUnoXHatchTable";
505 }
506 
507 uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( )
508 {
509  return { "com.sun.star.drawing.HatchTable" };
510 }
511 
512 namespace {
513 
514 class SvxUnoXGradientTable : public SvxUnoXPropertyTable
515 {
516 public:
517  explicit SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
518 
519  // SvxUnoXPropertyTable
520  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() override;
521  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
522 
523  // XElementAccess
524  virtual uno::Type SAL_CALL getElementType() override;
525 
526  // XServiceInfo
527  virtual OUString SAL_CALL getImplementationName( ) override;
528  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
529 };
530 
531 }
532 
533 uno::Reference< uno::XInterface > SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
534 {
535  return static_cast<OWeakObject*>(new SvxUnoXGradientTable( pTable ));
536 }
537 
538 // SvxUnoXPropertyTable
539 uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
540 {
541  const XGradient& aXGradient = static_cast<const XGradientEntry*>(pEntry)->GetGradient();
542  awt::Gradient aGradient;
543 
544  aGradient.Style = aXGradient.GetGradientStyle();
545  aGradient.StartColor = static_cast<sal_Int32>(aXGradient.GetStartColor());
546  aGradient.EndColor = static_cast<sal_Int32>(aXGradient.GetEndColor());
547  aGradient.Angle = static_cast<short>(aXGradient.GetAngle());
548  aGradient.Border = aXGradient.GetBorder();
549  aGradient.XOffset = aXGradient.GetXOffset();
550  aGradient.YOffset = aXGradient.GetYOffset();
551  aGradient.StartIntensity = aXGradient.GetStartIntens();
552  aGradient.EndIntensity = aXGradient.GetEndIntens();
553  aGradient.StepCount = aXGradient.GetSteps();
554 
555  return uno::Any(aGradient);
556 }
557 
558 std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString& rName, const uno::Any& rAny) const
559 {
560  awt::Gradient aGradient;
561  if(!(rAny >>= aGradient))
562  return std::unique_ptr<XPropertyEntry>();
563 
564  XGradient aXGradient;
565 
566  aXGradient.SetGradientStyle( aGradient.Style );
567  aXGradient.SetStartColor( Color(aGradient.StartColor) );
568  aXGradient.SetEndColor( Color(aGradient.EndColor) );
569  aXGradient.SetAngle( aGradient.Angle );
570  aXGradient.SetBorder( aGradient.Border );
571  aXGradient.SetXOffset( aGradient.XOffset );
572  aXGradient.SetYOffset( aGradient.YOffset );
573  aXGradient.SetStartIntens( aGradient.StartIntensity );
574  aXGradient.SetEndIntens( aGradient.EndIntensity );
575  aXGradient.SetSteps( aGradient.StepCount );
576 
577  return std::make_unique<XGradientEntry>(aXGradient, rName);
578 }
579 
580 // XElementAccess
581 uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
582 {
584 }
585 
586 // XServiceInfo
587 OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( )
588 {
589  return "SvxUnoXGradientTable";
590 }
591 
592 uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( )
593 {
594  return { "com.sun.star.drawing.GradientTable" };
595 }
596 
597 namespace {
598 
599 class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
600 {
601 public:
602  explicit SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
603 
604  // SvxUnoXPropertyTable
605  virtual uno::Any getAny( const XPropertyEntry* pEntry ) const override;
606  virtual std::unique_ptr<XPropertyEntry> createEntry(const OUString& rName, const uno::Any& rAny) const override;
607 
608  // XElementAccess
609  virtual uno::Type SAL_CALL getElementType() override;
610 
611  // XServiceInfo
612  virtual OUString SAL_CALL getImplementationName( ) override;
613  virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
614 };
615 
616 }
617 
618 uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
619 {
620  return static_cast<OWeakObject*>(new SvxUnoXBitmapTable( pTable ));
621 }
622 
623 // SvxUnoXPropertyTable
624 uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const
625 {
626  auto xBitmapEntry = static_cast<const XBitmapEntry*>(pEntry);
627  css::uno::Reference<css::awt::XBitmap> xBitmap(xBitmapEntry->GetGraphicObject().GetGraphic().GetXGraphic(), uno::UNO_QUERY);
628  return uno::Any(xBitmap);
629 }
630 
631 std::unique_ptr<XPropertyEntry> SvxUnoXBitmapTable::createEntry(const OUString& rName, const uno::Any& rAny) const
632 {
633  if (!rAny.has<uno::Reference<awt::XBitmap>>())
634  return std::unique_ptr<XPropertyEntry>();
635 
636  auto xBitmap = rAny.get<uno::Reference<awt::XBitmap>>();
637  if (!xBitmap.is())
638  return nullptr;
639 
640  uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
641  if (!xGraphic.is())
642  return nullptr;
643 
644  Graphic aGraphic(xGraphic);
645  if (aGraphic.IsNone())
646  return nullptr;
647 
648  GraphicObject aGraphicObject(aGraphic);
649  return std::make_unique<XBitmapEntry>(aGraphicObject, rName);
650 }
651 
652 // XElementAccess
653 uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
654 {
655  return ::cppu::UnoType<awt::XBitmap>::get();
656 }
657 
658 // XServiceInfo
659 OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( )
660 {
661  return "SvxUnoXBitmapTable";
662 }
663 
664 uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( )
665 {
666  return { "com.sun.star.drawing.BitmapTable" };
667 }
668 
669 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XPropertyEntry * Get(long nIndex) const
Definition: xtable.cxx:131
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
void SetHatchStyle(css::drawing::HatchStyle eNewStyle)
Definition: xhatch.hxx:44
void setClosed(bool bNew)
sal_uInt32 GetDistance() const
Definition: xdash.hxx:59
OUString getImplementationName()
OUString SvxUnogetApiNameForItem(const sal_uInt16 nWhich, const OUString &rInternalName)
if the given name is a predefined name for the current language it is replaced by the corresponding a...
Definition: unoprov.cxx:1930
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
sal_uInt16 GetStartIntens() const
Definition: xgrad.hxx:73
void Insert(std::unique_ptr< XPropertyEntry > pEntry, long nIndex=std::numeric_limits< long >::max())
Definition: xtable.cxx:177
uno::Reference< uno::XInterface > SvxUnoXLineEndTable_createInstance(XPropertyList *pTable)
const Color & GetStartColor() const
Definition: xgrad.hxx:67
void Replace(std::unique_ptr< XPropertyEntry > pEntry, long nIndex)
Definition: xtable.cxx:192
sal_uInt16 GetYOffset() const
Definition: xgrad.hxx:72
Definition: xdash.hxx:31
uno::Reference< uno::XInterface > SvxUnoXBitmapTable_createInstance(XPropertyList *pTable)
OUString SvxUnogetInternalNameForItem(const sal_uInt16 nWhich, const OUString &rApiName)
if the given name is a predefined api name it is replaced by the predefined name for the current lang...
Definition: unoprov.cxx:1963
int nCount
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_uInt16 GetDots() const
Definition: xdash.hxx:55
css::drawing::DashStyle GetDashStyle() const
Definition: xdash.hxx:54
sal_uInt16 GetXOffset() const
Definition: xgrad.hxx:71
const OUString & GetName() const
uno::Reference< uno::XInterface > SvxUnoXDashTable_createInstance(XPropertyList *pTable)
long GetDistance() const
Definition: xhatch.hxx:51
sal_uInt16 GetBorder() const
Definition: xgrad.hxx:70
css::uno::Sequence< OUString > getSupportedServiceNames()
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
int i
css::drawing::HatchStyle GetHatchStyle() const
Definition: xhatch.hxx:49
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
long GetAngle() const
Definition: xhatch.hxx:52
B2DPolyPolygon UnoPolyPolygonBezierCoordsToB2DPolyPolygon(const css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsSource)
void SetGradientStyle(css::awt::GradientStyle eNewStyle)
Definition: xgrad.hxx:55
long GetAngle() const
Definition: xgrad.hxx:69
sal_uInt16 GetSteps() const
Definition: xgrad.hxx:75
void Remove(long nIndex)
Definition: xtable.cxx:208
unsigned char sal_Bool
void SetDashStyle(css::drawing::DashStyle eNewStyle)
Definition: xdash.hxx:47
css::uno::Type const & get()
tuple index
const Color & GetColor() const
Definition: xhatch.hxx:50
css::awt::GradientStyle GetGradientStyle() const
Definition: xgrad.hxx:66
sal_uInt32 GetDotLen() const
Definition: xdash.hxx:56
uno::Reference< uno::XInterface > SvxUnoXGradientTable_createInstance(XPropertyList *pTable)
long Count() const
Definition: xtable.cxx:121
EdgeEntry * mpList
uno::Reference< uno::XInterface > SvxUnoXHatchTable_createInstance(XPropertyList *pTable)
void B2DPolyPolygonToUnoPolyPolygonBezierCoords(const B2DPolyPolygon &rPolyPolygon, css::drawing::PolyPolygonBezierCoords &rPolyPolygonBezierCoordsRetval)
sal_uInt32 GetDashLen() const
Definition: xdash.hxx:58
constexpr TypedWhichId< XLineColorItem > XATTR_LINECOLOR(XATTR_LINE_FIRST+3)
sal_uInt16 GetEndIntens() const
Definition: xgrad.hxx:74
Reference< XGraphic > xGraphic
uno::Reference< uno::XInterface > SvxUnoXColorTable_createInstance(XPropertyList *pList)
const Color & GetEndColor() const
Definition: xgrad.hxx:68
sal_uInt16 GetDashes() const
Definition: xdash.hxx:57