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