LibreOffice Module svx (master)  1
svdetc.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 #include <sal/config.h>
21 
23 #include <officecfg/Office/Common.hxx>
24 #include <svx/dialmgr.hxx>
25 #include <svx/svdetc.hxx>
26 #include <svx/svdmodel.hxx>
27 #include <svx/svdtrans.hxx>
28 #include <svx/strings.hrc>
29 #include <svx/svdviter.hxx>
30 #include <svx/svdview.hxx>
31 #include <svx/svdoutl.hxx>
32 #include <vcl/bitmapaccess.hxx>
33 #include <editeng/editdata.hxx>
34 #include <editeng/eeitem.hxx>
35 #include <svl/itemset.hxx>
36 #include <svl/whiter.hxx>
37 #include <editeng/fontitem.hxx>
38 #include <editeng/colritem.hxx>
39 #include <editeng/fhgtitem.hxx>
40 #include <svx/xgrad.hxx>
41 #include <svx/xfillit0.hxx>
42 #include <svx/xflclit.hxx>
43 #include <svx/xflhtit.hxx>
44 #include <svx/xbtmpit.hxx>
45 #include <svx/xflgrit.hxx>
46 #include <svx/svdoole2.hxx>
47 #include <svl/itempool.hxx>
48 #include <unotools/configmgr.hxx>
50 #include <i18nlangtag/lang.h>
51 #include <unotools/syslocale.hxx>
52 #include <svx/xflbckit.hxx>
53 #include <svx/extrusionbar.hxx>
54 #include <svx/fontworkbar.hxx>
55 #include <vcl/svapp.hxx>
56 #include <vcl/settings.hxx>
58 #include <svx/svdpage.hxx>
59 #include <svx/svdpagv.hxx>
60 #include <svx/svdotable.hxx>
61 #include <svx/sdrhittesthelper.hxx>
62 
63 #include <com/sun/star/frame/XModel.hpp>
64 #include <com/sun/star/embed/XEmbeddedObject.hpp>
65 #include <com/sun/star/embed/EmbedStates.hpp>
66 #include <com/sun/star/lang/Locale.hpp>
67 
68 using namespace ::com::sun::star;
69 
70 // Global data of the DrawingEngine
72  : pSysLocale(nullptr)
73  , pLocaleData(nullptr)
74 {
76  {
77  svx::ExtrusionBar::RegisterInterface();
78  svx::FontworkBar::RegisterInterface();
79  }
80 }
81 
83 {
84  if ( !pSysLocale )
86  return pSysLocale;
87 }
89 {
90  if ( !pLocaleData )
92  return pLocaleData;
93 }
94 
95 namespace {
96 
97 struct TheSdrGlobalData: public rtl::Static<SdrGlobalData, TheSdrGlobalData> {};
98 
99 }
100 
102  return TheSdrGlobalData::get();
103 }
104 
106 {
108  nSize = officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::get();
109  else
110  nSize = 100;
111  pTimer.reset( new AutoTimer( "svx OLEObjCache pTimer UnloadCheck" ) );
112  pTimer->SetInvokeHandler( LINK(this, OLEObjCache, UnloadCheckHdl) );
113  pTimer->SetTimeout(20000);
114  pTimer->SetStatic();
115 }
116 
118 {
119  pTimer->Stop();
120 }
121 
122 IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer*, void)
123 {
124  if (nSize >= maObjs.size())
125  return;
126 
127  // more objects than configured cache size try to remove objects
128  // of course not the freshly inserted one at nIndex=0
129  size_t nCount2 = maObjs.size();
130  size_t nIndex = nCount2-1;
131  while( nIndex && nCount2 > nSize )
132  {
133  SdrOle2Obj* pUnloadObj = maObjs[nIndex--];
134  if (!pUnloadObj)
135  continue;
136 
137  try
138  {
139  // it is important to get object without reinitialization to avoid reentrance
140  uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit();
141 
142  bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() );
143 
144  // check whether the object can be unloaded before looking for the parent objects
145  if ( xUnloadObj.is() && bUnload )
146  {
147  uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
148  if ( xUnloadModel.is() )
149  {
150  for (SdrOle2Obj* pCacheObj : maObjs)
151  {
152  if ( pCacheObj && pCacheObj != pUnloadObj )
153  {
154  uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
155  if ( xUnloadModel == xParentModel )
156  bUnload = false; // the object has running embedded objects
157  }
158  }
159  }
160  }
161 
162  if ( bUnload && UnloadObj(pUnloadObj) )
163  // object was successfully unloaded
164  nCount2--;
165  }
166  catch( uno::Exception& )
167  {}
168  }
169 }
170 
172 {
173  if (!maObjs.empty())
174  {
175  SdrOle2Obj* pExistingObj = maObjs.front();
176  if ( pObj == pExistingObj )
177  // the object is already on the top, nothing has to be changed
178  return;
179  }
180 
181  // get the old position of the object to know whether it is already in container
182  std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
183  bool bFound = it != maObjs.end();
184 
185  if (bFound)
186  maObjs.erase(it);
187  // insert object into first position
188  maObjs.insert(maObjs.begin(), pObj);
189 
190  // if a new object was inserted, recalculate the cache
191  if (!bFound)
192  pTimer->Invoke();
193 
194  if (!bFound || !pTimer->IsActive())
195  pTimer->Start();
196 }
197 
199 {
200  std::vector<SdrOle2Obj*>::iterator it = std::find(maObjs.begin(), maObjs.end(), pObj);
201  if (it != maObjs.end())
202  maObjs.erase(it);
203  if (maObjs.empty())
204  pTimer->Stop();
205 }
206 
207 size_t OLEObjCache::size() const
208 {
209  return maObjs.size();
210 }
211 
213 {
214  return maObjs[nPos];
215 }
216 
217 const SdrOle2Obj* OLEObjCache::operator[](size_t nPos) const
218 {
219  return maObjs[nPos];
220 }
221 
223 {
224  bool bUnloaded = false;
225  if (pObj)
226  {
227  //#i80528# The old mechanism is completely useless, only taking into account if
228  // in all views the GrafDraft feature is used. This will nearly never have been the
229  // case since no one ever used this option.
230 
231  // A much better (and working) criteria would be the VOC contact count.
232  // The question is what will happen when i make it work now suddenly? I
233  // will try it for 2.4.
234  const sdr::contact::ViewContact& rViewContact = pObj->GetViewContact();
235  const bool bVisible(rViewContact.HasViewObjectContacts());
236 
237  if(!bVisible)
238  {
239  bUnloaded = pObj->Unload();
240  }
241  }
242 
243  return bUnloaded;
244 }
245 
246 bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol)
247 {
248  drawing::FillStyle eFill=rSet.Get(XATTR_FILLSTYLE).GetValue();
249  bool bRetval = false;
250 
251  switch(eFill)
252  {
253  case drawing::FillStyle_SOLID:
254  {
255  rCol = rSet.Get(XATTR_FILLCOLOR).GetColorValue();
256  bRetval = true;
257 
258  break;
259  }
260  case drawing::FillStyle_HATCH:
261  {
262  Color aCol1(rSet.Get(XATTR_FILLHATCH).GetHatchValue().GetColor());
263  Color aCol2(COL_WHITE);
264 
265  // when hatched background is activated, use object fill color as hatch color
266  bool bFillHatchBackground = rSet.Get(XATTR_FILLBACKGROUND).GetValue();
267  if(bFillHatchBackground)
268  {
269  aCol2 = rSet.Get(XATTR_FILLCOLOR).GetColorValue();
270  }
271 
272  const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
273  rCol = Color(aAverageColor);
274  bRetval = true;
275 
276  break;
277  }
278  case drawing::FillStyle_GRADIENT: {
279  const XGradient& rGrad=rSet.Get(XATTR_FILLGRADIENT).GetGradientValue();
280  Color aCol1(rGrad.GetStartColor());
281  Color aCol2(rGrad.GetEndColor());
282  const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
283  rCol = Color(aAverageColor);
284  bRetval = true;
285 
286  break;
287  }
288  case drawing::FillStyle_BITMAP:
289  {
290  Bitmap aBitmap(rSet.Get(XATTR_FILLBITMAP).GetGraphicObject().GetGraphic().GetBitmapEx().GetBitmap());
291  const Size aSize(aBitmap.GetSizePixel());
292  const sal_uInt32 nWidth = aSize.Width();
293  const sal_uInt32 nHeight = aSize.Height();
294  if (nWidth <= 0 || nHeight <= 0)
295  return bRetval;
296 
297  Bitmap::ScopedReadAccess pAccess(aBitmap);
298 
299  if (pAccess)
300  {
301  sal_uInt32 nRt(0);
302  sal_uInt32 nGn(0);
303  sal_uInt32 nBl(0);
304  const sal_uInt32 nMaxSteps(8);
305  const sal_uInt32 nXStep((nWidth > nMaxSteps) ? nWidth / nMaxSteps : 1);
306  const sal_uInt32 nYStep((nHeight > nMaxSteps) ? nHeight / nMaxSteps : 1);
307  sal_uInt32 nCount(0);
308 
309  for(sal_uInt32 nY(0); nY < nHeight; nY += nYStep)
310  {
311  for(sal_uInt32 nX(0); nX < nWidth; nX += nXStep)
312  {
313  const BitmapColor& rCol2 = pAccess->GetColor(nY, nX);
314 
315  nRt += rCol2.GetRed();
316  nGn += rCol2.GetGreen();
317  nBl += rCol2.GetBlue();
318  nCount++;
319  }
320  }
321 
322  nRt /= nCount;
323  nGn /= nCount;
324  nBl /= nCount;
325 
326  rCol = Color(sal_uInt8(nRt), sal_uInt8(nGn), sal_uInt8(nBl));
327 
328  bRetval = true;
329  }
330  break;
331  }
332  default: break;
333  }
334 
335  return bRetval;
336 }
337 
338 std::unique_ptr<SdrOutliner> SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel& rModel)
339 {
340  SfxItemPool* pPool = &rModel.GetItemPool();
341  std::unique_ptr<SdrOutliner> pOutl(new SdrOutliner( pPool, nOutlinerMode ));
342  pOutl->SetEditTextObjectPool( pPool );
343  pOutl->SetStyleSheetPool( static_cast<SfxStyleSheetPool*>(rModel.GetStyleSheetPool()));
344  pOutl->SetDefTab(rModel.GetDefaultTabulator());
346  pOutl->SetAsianCompressionMode(rModel.GetCharCompressType());
347  pOutl->SetKernAsianPunctuation(rModel.IsKernAsianPunctuation());
348  pOutl->SetAddExtLeading(rModel.IsAddExtLeading());
349  return pOutl;
350 }
351 
352 std::vector<Link<SdrObjCreatorParams, SdrObject*>>& ImpGetUserMakeObjHdl()
353 {
354  SdrGlobalData& rGlobalData=GetSdrGlobalData();
355  return rGlobalData.aUserMakeObjHdl;
356 }
357 
358 bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnlyEE)
359 {
360  bool bHas=false;
361  bool bOnly=true;
362  bool bLookOnly=pbOnlyEE!=nullptr;
363  SfxWhichIter aIter(rSet);
364  sal_uInt16 nWhich=aIter.FirstWhich();
365  while (((bLookOnly && bOnly) || !bHas) && nWhich!=0) {
366  // For bInklDefaults, the entire Which range is decisive,
367  // in other cases only the set items are.
368  // Disabled and DontCare are regarded as holes in the Which range.
369  SfxItemState eState=rSet.GetItemState(nWhich);
370  if ((eState==SfxItemState::DEFAULT && bInklDefaults) || eState==SfxItemState::SET) {
371  if (nWhich<EE_ITEMS_START || nWhich>EE_ITEMS_END) bOnly=false;
372  else bHas=true;
373  }
374  nWhich=aIter.NextWhich();
375  }
376  if (!bHas) bOnly=false;
377  if (pbOnlyEE!=nullptr) *pbOnlyEE=bOnly;
378  return bHas;
379 }
380 
381 std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
382 {
383  // Six possible cases (per range):
384  // [Beg..End] Range, to delete
385  // [b..e] [b..e] [b..e] Cases 1,3,2: doesn't matter, delete, doesn't matter + Ranges
386  // [b........e] [b........e] Cases 4,5 : shrink range | in
387  // [b......................e] Case 6 : splitting + pOldWhichTable
388  sal_uInt16 nCount=0;
389  while (pOldWhichTable[nCount]!=0) nCount++;
390  nCount++; // nCount should now be an odd number (0 for end of array)
391  DBG_ASSERT((nCount&1)==1,"RemoveWhichRange: WhichTable doesn't have an odd number of entries.");
392  sal_uInt16 nAlloc=nCount;
393  // check necessary size of new array
394  sal_uInt16 nNum=nCount-1;
395  while (nNum!=0) {
396  nNum-=2;
397  sal_uInt16 nBeg=pOldWhichTable[nNum];
398  sal_uInt16 nEnd=pOldWhichTable[nNum+1];
399  if (nEnd<nRangeBeg) /*nCase=1*/ ;
400  else if (nBeg>nRangeEnd) /* nCase=2 */ ;
401  else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) /* nCase=3 */ nAlloc-=2;
402  else if (nEnd<=nRangeEnd) /* nCase=4 */;
403  else if (nBeg>=nRangeBeg) /* nCase=5*/ ;
404  else /* nCase=6 */ nAlloc+=2;
405  }
406 
407  std::unique_ptr<sal_uInt16[]> pNewWhichTable(new sal_uInt16[nAlloc]);
408  memcpy(pNewWhichTable.get(), pOldWhichTable, nAlloc*sizeof(sal_uInt16));
409  pNewWhichTable[nAlloc-1]=0; // in case 3, there's no 0 at the end.
410  // now remove the unwanted ranges
411  nNum=nAlloc-1;
412  while (nNum!=0) {
413  nNum-=2;
414  sal_uInt16 nBeg=pNewWhichTable[nNum];
415  sal_uInt16 nEnd=pNewWhichTable[nNum+1];
416  unsigned nCase=0;
417  if (nEnd<nRangeBeg) nCase=1;
418  else if (nBeg>nRangeEnd) nCase=2;
419  else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) nCase=3;
420  else if (nEnd<=nRangeEnd) nCase=4;
421  else if (nBeg>=nRangeBeg) nCase=5;
422  else nCase=6;
423  switch (nCase) {
424  case 3: {
425  unsigned nTailBytes=(nCount-(nNum+2))*sizeof(sal_uInt16);
426  memcpy(&pNewWhichTable[nNum],&pNewWhichTable[nNum+2],nTailBytes);
427  nCount-=2; // remember: array is now smaller
428  } break;
429  case 4: pNewWhichTable[nNum+1]=nRangeBeg-1; break;
430  case 5: pNewWhichTable[nNum]=nRangeEnd+1; break;
431  case 6: {
432  unsigned nTailBytes=(nCount-(nNum+2))*sizeof(sal_uInt16);
433  memcpy(&pNewWhichTable[nNum+4],&pNewWhichTable[nNum+2],nTailBytes);
434  nCount+=2; // remember:array is now larger
435  pNewWhichTable[nNum+2]=nRangeEnd+1;
436  pNewWhichTable[nNum+3]=pNewWhichTable[nNum+1];
437  pNewWhichTable[nNum+1]=nRangeBeg-1;
438  } break;
439  } // switch
440  }
441  return pNewWhichTable;
442 }
443 
444 
446 {
447  maLink = _rLink;
448  m_nSumCurAction = 0;
449 
450  m_nObjCount = 0;
451  m_nCurObj = 0;
452 
453  m_nActionCount = 0;
454  m_nCurAction = 0;
455 
456  m_nInsertCount = 0;
457  m_nCurInsert = 0;
458 }
459 
460 void SvdProgressInfo::Init( size_t nObjCount )
461 {
462  m_nObjCount = nObjCount;
463 }
464 
465 bool SvdProgressInfo::ReportActions( size_t nActionCount )
466 {
467  m_nSumCurAction += nActionCount;
468  m_nCurAction += nActionCount;
471 
472  return maLink.Call(nullptr);
473 }
474 
475 void SvdProgressInfo::ReportInserts( size_t nInsertCount )
476 {
477  m_nSumCurAction += nInsertCount;
478  m_nCurInsert += nInsertCount;
479 
480  maLink.Call(nullptr);
481 }
482 
483 void SvdProgressInfo::ReportRescales( size_t nRescaleCount )
484 {
485  m_nSumCurAction += nRescaleCount;
486  maLink.Call(nullptr);
487 }
488 
489 void SvdProgressInfo::SetActionCount( size_t nActionCount )
490 {
491  m_nActionCount = nActionCount;
492 }
493 
494 void SvdProgressInfo::SetInsertCount( size_t nInsertCount )
495 {
496  m_nInsertCount = nInsertCount;
497 }
498 
500 {
501  m_nActionCount = 0;
502  m_nCurAction = 0;
503 
504  m_nInsertCount = 0;
505  m_nCurInsert = 0;
506 
507  m_nCurObj++;
508  ReportActions(0);
509 }
510 
511 // #i101872# isolate GetTextEditBackgroundColor to tooling; it will anyways only be used as long
512 // as text edit is not running on overlay
513 
514 namespace
515 {
516  bool impGetSdrObjListFillColor(
517  const SdrObjList& rList,
518  const Point& rPnt,
519  const SdrPageView& rTextEditPV,
520  const SdrLayerIDSet& rVisLayers,
521  Color& rCol)
522  {
523  bool bRet(false);
524  bool bMaster(rList.getSdrPageFromSdrObjList() && rList.getSdrPageFromSdrObjList()->IsMasterPage());
525 
526  for(size_t no(rList.GetObjCount()); !bRet && no > 0; )
527  {
528  no--;
529  SdrObject* pObj = rList.GetObj(no);
530  SdrObjList* pOL = pObj->GetSubList();
531 
532  if(pOL)
533  {
534  // group object
535  bRet = impGetSdrObjListFillColor(*pOL, rPnt, rTextEditPV, rVisLayers, rCol);
536  }
537  else
538  {
539  SdrTextObj* pText = dynamic_cast< SdrTextObj * >(pObj);
540 
541  // Exclude zero master page object (i.e. background shape) from color query
542  if(pText
543  && pObj->IsClosedObj()
544  && (!bMaster || (!pObj->IsNotVisibleAsMaster() && 0 != no))
545  && pObj->GetCurrentBoundRect().IsInside(rPnt)
546  && !pText->IsHideContour()
547  && SdrObjectPrimitiveHit(*pObj, rPnt, 0, rTextEditPV, &rVisLayers, false))
548  {
549  bRet = GetDraftFillColor(pObj->GetMergedItemSet(), rCol);
550  }
551  }
552  }
553 
554  return bRet;
555  }
556 
557  bool impGetSdrPageFillColor(
558  const SdrPage& rPage,
559  const Point& rPnt,
560  const SdrPageView& rTextEditPV,
561  const SdrLayerIDSet& rVisLayers,
562  Color& rCol,
563  bool bSkipBackgroundShape)
564  {
565  bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
566 
567  if(!bRet && !rPage.IsMasterPage())
568  {
569  if(rPage.TRG_HasMasterPage())
570  {
571  SdrLayerIDSet aSet(rVisLayers);
572  aSet &= rPage.TRG_GetMasterPageVisibleLayers();
573  SdrPage& rMasterPage = rPage.TRG_GetMasterPage();
574 
575  // Don't fall back to background shape on
576  // master pages. This is later handled by
577  // GetBackgroundColor, and is necessary to cater for
578  // the silly ordering: 1. shapes, 2. master page
579  // shapes, 3. page background, 4. master page
580  // background.
581  bRet = impGetSdrPageFillColor(rMasterPage, rPnt, rTextEditPV, aSet, rCol, true);
582  }
583  }
584 
585  // Only now determine background color from background shapes
586  if(!bRet && !bSkipBackgroundShape)
587  {
588  rCol = rPage.GetPageBackgroundColor();
589  return true;
590  }
591 
592  return bRet;
593  }
594 
595  Color impCalcBackgroundColor(
596  const tools::Rectangle& rArea,
597  const SdrPageView& rTextEditPV,
598  const SdrPage& rPage)
599  {
600  svtools::ColorConfig aColorConfig;
601  Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
602  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
603 
604  if(!rStyleSettings.GetHighContrastMode())
605  {
606  // search in page
607  const sal_uInt16 SPOTCOUNT(5);
608  Point aSpotPos[SPOTCOUNT];
609  Color aSpotColor[SPOTCOUNT];
610  sal_uInt32 nHeight( rArea.GetSize().Height() );
611  sal_uInt32 nWidth( rArea.GetSize().Width() );
612  sal_uInt32 nWidth14 = nWidth / 4;
613  sal_uInt32 nHeight14 = nHeight / 4;
614  sal_uInt32 nWidth34 = ( 3 * nWidth ) / 4;
615  sal_uInt32 nHeight34 = ( 3 * nHeight ) / 4;
616 
617  sal_uInt16 i;
618  for ( i = 0; i < SPOTCOUNT; i++ )
619  {
620  // five spots are used
621  switch ( i )
622  {
623  case 0 :
624  {
625  // Center-Spot
626  aSpotPos[i] = rArea.Center();
627  }
628  break;
629 
630  case 1 :
631  {
632  // TopLeft-Spot
633  aSpotPos[i] = rArea.TopLeft();
634  aSpotPos[i].AdjustX(nWidth14 );
635  aSpotPos[i].AdjustY(nHeight14 );
636  }
637  break;
638 
639  case 2 :
640  {
641  // TopRight-Spot
642  aSpotPos[i] = rArea.TopLeft();
643  aSpotPos[i].AdjustX(nWidth34 );
644  aSpotPos[i].AdjustY(nHeight14 );
645  }
646  break;
647 
648  case 3 :
649  {
650  // BottomLeft-Spot
651  aSpotPos[i] = rArea.TopLeft();
652  aSpotPos[i].AdjustX(nWidth14 );
653  aSpotPos[i].AdjustY(nHeight34 );
654  }
655  break;
656 
657  case 4 :
658  {
659  // BottomRight-Spot
660  aSpotPos[i] = rArea.TopLeft();
661  aSpotPos[i].AdjustX(nWidth34 );
662  aSpotPos[i].AdjustY(nHeight34 );
663  }
664  break;
665 
666  }
667 
668  aSpotColor[i] = COL_WHITE;
669  impGetSdrPageFillColor(rPage, aSpotPos[i], rTextEditPV, rTextEditPV.GetVisibleLayers(), aSpotColor[i], false);
670  }
671 
672  sal_uInt16 aMatch[SPOTCOUNT];
673 
674  for ( i = 0; i < SPOTCOUNT; i++ )
675  {
676  // were same spot colors found?
677  aMatch[i] = 0;
678 
679  for ( sal_uInt16 j = 0; j < SPOTCOUNT; j++ )
680  {
681  if( j != i )
682  {
683  if( aSpotColor[i] == aSpotColor[j] )
684  {
685  aMatch[i]++;
686  }
687  }
688  }
689  }
690 
691  // highest weight to center spot
692  aBackground = aSpotColor[0];
693 
694  for ( sal_uInt16 nMatchCount = SPOTCOUNT - 1; nMatchCount > 1; nMatchCount-- )
695  {
696  // which spot color was found most?
697  for ( i = 0; i < SPOTCOUNT; i++ )
698  {
699  if( aMatch[i] == nMatchCount )
700  {
701  aBackground = aSpotColor[i];
702  nMatchCount = 1; // break outer for-loop
703  break;
704  }
705  }
706  }
707  }
708 
709  return aBackground;
710  }
711 } // end of anonymous namespace
712 
714 {
715  svtools::ColorConfig aColorConfig;
716  Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
717  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
718 
719  if(!rStyleSettings.GetHighContrastMode())
720  {
721  bool bFound(false);
722  SdrTextObj* pText = rView.GetTextEditObject();
723 
724  if(pText && pText->IsClosedObj())
725  {
726  sdr::table::SdrTableObj* pTable = dynamic_cast< sdr::table::SdrTableObj * >( pText );
727 
728  if( pTable )
729  bFound = GetDraftFillColor(pTable->GetActiveCellItemSet(), aBackground );
730 
731  if( !bFound )
732  bFound=GetDraftFillColor(pText->GetMergedItemSet(), aBackground);
733  }
734 
735  if(!bFound && pText)
736  {
737  SdrPageView* pTextEditPV = rView.GetTextEditPageView();
738 
739  if(pTextEditPV)
740  {
741  Point aPvOfs(pText->GetTextEditOffset());
742  const SdrPage* pPg = pTextEditPV->GetPage();
743 
744  if(pPg)
745  {
746  tools::Rectangle aSnapRect( pText->GetSnapRect() );
747  aSnapRect.Move(aPvOfs.X(), aPvOfs.Y());
748 
749  return impCalcBackgroundColor(aSnapRect, *pTextEditPV, *pPg);
750  }
751  }
752  }
753  }
754 
755  return aBackground;
756 }
757 
758 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Point TopLeft() const
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1580
long Width() const
void ReportRescales(size_t nRescaleCount)
Definition: svdetc.cxx:483
#define XATTR_FILLHATCH
Definition: xdef.hxx:110
sal_Int32 nIndex
bool SearchOutlinerItems(const SfxItemSet &rSet, bool bInklDefaults, bool *pbOnlyEE)
Search an ItemSet for Outliner/EditEngine Items.
Definition: svdetc.cxx:358
bool bVisible
OutlinerMode
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:882
bool IsClosedObj() const
Definition: svdobj.hxx:787
virtual const tools::Rectangle & GetCurrentBoundRect() const
Definition: svdobj.cxx:881
const SvtSysLocale * GetSysLocale()
Definition: svdetc.cxx:82
CharCompressType GetCharCompressType() const
Definition: svdmodel.hxx:559
const LocaleDataWrapper * GetLocaleDataPtr() const
Color GetPageBackgroundColor() const
deprecated returns an averaged background color of this page
Definition: svdpage.cxx:1746
long AdjustX(long nHorzMove)
bool IsKernAsianPunctuation() const
Definition: svdmodel.hxx:562
long Height() const
SdrTextObj * GetTextEditObject() const
Definition: svdedxv.hxx:223
std::vector< Link< SdrObjCreatorParams, SdrObject * > > & ImpGetUserMakeObjHdl()
Definition: svdetc.cxx:352
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void SetNextObject()
Definition: svdetc.cxx:499
#define XATTR_FILLGRADIENT
Definition: xdef.hxx:109
SdrObject * GetObj(size_t nNum) const
Definition: svdpage.cxx:773
size_t GetObjCount() const
Definition: svdpage.cxx:767
std::unique_ptr< sal_uInt16[]> RemoveWhichRange(const sal_uInt16 *pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
Definition: svdetc.cxx:381
sal_uInt16 FirstWhich()
B2DTuple average(const B2DTuple &rOld1, const B2DTuple &rOld2)
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdoattr.cxx:91
SVX_DLLPUBLIC ~OLEObjCache()
Definition: svdetc.cxx:117
virtual SdrObjList * GetSubList() const
Definition: svdobj.cxx:674
#define XATTR_FILLCOLOR
Definition: xdef.hxx:108
sdr::contact::ViewContact & GetViewContact() const
Definition: svdobj.cxx:271
sal_uInt16 NextWhich()
void Move(long nHorzMoveDelta, long nVertMoveDelta)
const Color & GetStartColor() const
Definition: xgrad.hxx:67
const SvtSysLocale * pSysLocale
Definition: svdetc.hxx:184
static bool IsFuzzing()
int nCount
void Init(size_t _nObjCount)
Definition: svdetc.cxx:460
const LocaleDataWrapper * GetLocaleData()
Definition: svdetc.cxx:88
void RemoveObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:198
SdrObject * SdrObjectPrimitiveHit(const SdrObject &rObject, const Point &rPnt, sal_uInt16 nTol, const SdrPageView &rSdrPageView, const SdrLayerIDSet *pVisiLayer, bool bTextOnly, drawinglayer::primitive2d::Primitive2DContainer *pHitContainer)
const LocaleDataWrapper * pLocaleData
Definition: svdetc.hxx:185
std::vector< SdrOle2Obj * > maObjs
Definition: svdetc.hxx:161
const Point & GetTextEditOffset() const
Definition: svdotext.hxx:216
static bool Unload(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
SVX_DLLPRIVATE css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef_NoInit() const
Definition: svdoole2.cxx:1829
static bool UnloadObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:222
size_t nSize
Definition: svdetc.hxx:163
void SetInsertCount(size_t _nInsertCount)
Definition: svdetc.cxx:494
void SetActionCount(size_t _nActionCount)
Definition: svdetc.cxx:489
bool HasViewObjectContacts() const
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:217
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
long AdjustY(long nVertMove)
bool IsAddExtLeading() const
Definition: svdmodel.hxx:565
size_t m_nSumCurAction
Definition: svdetc.hxx:114
size_t m_nObjCount
Definition: svdetc.hxx:122
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
Definition: svdpage.cxx:1586
size_t m_nInsertCount
Definition: svdetc.hxx:119
size_t m_nActionCount
Definition: svdetc.hxx:116
int i
size_t m_nCurInsert
Definition: svdetc.hxx:120
Link< void *, bool > maLink
Definition: svdetc.hxx:125
static bool CanUnloadRunningObj(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
Definition: svdoole2.cxx:1691
bool IsHideContour() const
Definition: svdotext.cxx:1738
bool IsInside(const Point &rPOINT) const
bool IsMasterPage() const
Definition: svdpage.hxx:451
size_t m_nCurAction
Definition: svdetc.hxx:117
#define XATTR_FILLSTYLE
Definition: xdef.hxx:107
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:485
Abstract DrawObject.
Definition: svdobj.hxx:312
bool ReportActions(size_t nActionCount)
Definition: svdetc.cxx:465
Size GetSize() const
const SfxItemSet & GetActiveCellItemSet() const
Definition: svdotable.cxx:1275
SdrGlobalData & GetSdrGlobalData()
Definition: svdetc.cxx:101
const std::shared_ptr< SvxForbiddenCharactersTable > & GetForbiddenCharsTable() const
Definition: svdmodel.hxx:556
SfxItemState
sal_Int64 GetAspect() const
Definition: svdoole2.cxx:775
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
IMPL_LINK_NOARG(OLEObjCache, UnloadCheckHdl, Timer *, void)
Definition: svdetc.cxx:122
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SdrPageView * GetTextEditPageView() const
Definition: svdedxv.cxx:1667
unsigned char sal_uInt8
SdrPage * GetPage() const
Definition: svdpagv.hxx:173
BitmapColor GetColor(long nY, long nX) const
SfxStyleSheetBasePool * GetStyleSheetPool() const
Definition: svdmodel.hxx:538
Color GetTextEditBackgroundColor(const SdrObjEditView &rView)
Definition: svdetc.cxx:713
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1911
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
Definition: svdetc.cxx:338
static void SetForbiddenCharsTable(const std::shared_ptr< SvxForbiddenCharactersTable > &xForbiddenChars)
SvdProgressInfo(const Link< void *, bool > &_pLink)
Definition: svdetc.cxx:445
virtual SdrPage * getSdrPageFromSdrObjList() const
Definition: svdpage.cxx:146
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
void ReportInserts(size_t nInsertCount)
Definition: svdetc.cxx:475
#define XATTR_FILLBITMAP
Definition: xdef.hxx:111
const SfxItemPool & GetItemPool() const
Definition: svdmodel.hxx:314
std::vector< Link< SdrObjCreatorParams, SdrObject * > > aUserMakeObjHdl
Definition: svdetc.hxx:188
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
void InsertObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:171
SVX_DLLPUBLIC SdrOle2Obj * operator[](size_t nPos)
Definition: svdetc.cxx:212
size_t m_nCurObj
Definition: svdetc.hxx:123
bool GetDraftFillColor(const SfxItemSet &rSet, Color &rCol)
Returns a replacement for an XFillStyle.
Definition: svdetc.cxx:246
SVX_DLLPUBLIC size_t size() const
Definition: svdetc.cxx:207
Point Center() const
const Color & GetEndColor() const
Definition: xgrad.hxx:68
std::unique_ptr< AutoTimer > pTimer
Definition: svdetc.hxx:164
sal_uInt16 GetDefaultTabulator() const
Definition: svdmodel.hxx:337
#define XATTR_FILLBACKGROUND
Definition: xdef.hxx:126
#define EE_ITEMS_END