bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / table / TableDesignPane.cxx
blob3e6b665b524587091bbc7dcaa2bcde5b0520a3d7
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 .
20 #include <sddll.hxx>
22 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
23 #include <com/sun/star/frame/XController.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include <com/sun/star/style/XStyle.hpp>
26 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
28 #include <sfx2/viewfrm.hxx>
29 #include <vcl/virdev.hxx>
30 #include <vcl/layout.hxx>
31 #include <vcl/settings.hxx>
32 #include <vcl/builderfactory.hxx>
34 #include <tools/debug.hxx>
35 #include <svl/style.hxx>
36 #include <svl/stritem.hxx>
37 #include <sfx2/bindings.hxx>
38 #include <sfx2/app.hxx>
39 #include <sfx2/request.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <svx/svxids.hrc>
42 #include <svx/svdetc.hxx>
43 #include <editeng/boxitem.hxx>
44 #include <editeng/borderline.hxx>
45 #include <editeng/colritem.hxx>
46 #include <editeng/eeitem.hxx>
47 #include <svx/sdr/table/tabledesign.hxx>
48 #include <o3tl/enumrange.hxx>
50 #include "TableDesignPane.hxx"
51 #include <createtabledesignpanel.hxx>
53 #include <DrawDocShell.hxx>
54 #include <ViewShellBase.hxx>
55 #include <DrawViewShell.hxx>
56 #include <DrawController.hxx>
57 #include <EventMultiplexer.hxx>
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::uno;
61 using namespace ::com::sun::star::drawing;
62 using namespace ::com::sun::star::container;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::view;
65 using namespace ::com::sun::star::style;
66 using namespace ::com::sun::star::frame;
67 using namespace ::com::sun::star::lang;
68 using namespace ::com::sun::star::ui;
70 namespace sd {
72 static const sal_Int32 nPreviewColumns = 5;
73 static const sal_Int32 nPreviewRows = 5;
74 static const sal_Int32 nCellWidth = 12; // one pixel is shared with the next cell!
75 static const sal_Int32 nCellHeight = 7; // one pixel is shared with the next cell!
76 static const sal_Int32 nBitmapWidth = (nCellWidth * nPreviewColumns) - (nPreviewColumns - 1);
77 static const sal_Int32 nBitmapHeight = (nCellHeight * nPreviewRows) - (nPreviewRows - 1);
79 static const OUStringLiteral gPropNames[CB_COUNT] =
81 "UseFirstRowStyle",
82 "UseLastRowStyle",
83 "UseBandingRowStyle",
84 "UseFirstColumnStyle",
85 "UseLastColumnStyle",
86 "UseBandingColumnStyle"
89 TableDesignWidget::TableDesignWidget( VclBuilderContainer* pParent, ViewShellBase& rBase )
90 : mrBase(rBase)
92 pParent->get(m_pValueSet, "previews");
93 m_pValueSet->SetStyle(m_pValueSet->GetStyle() | WB_NO_DIRECTSELECT | WB_FLATVALUESET | WB_ITEMBORDER);
94 m_pValueSet->SetExtraSpacing(8);
95 m_pValueSet->setModal(false);
96 m_pValueSet->SetColor();
97 m_pValueSet->SetSelectHdl (LINK(this, TableDesignWidget, implValueSetHdl));
99 for (sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i)
101 pParent->get(m_aCheckBoxes[i], OString(gPropNames[i].data, gPropNames[i].size));
102 m_aCheckBoxes[i]->SetClickHdl( LINK( this, TableDesignWidget, implCheckBoxHdl ) );
105 // get current controller and initialize listeners
108 mxView.set(mrBase.GetController(), UNO_QUERY);
109 addListener();
111 Reference< XController > xController( mrBase.GetController(), UNO_SET_THROW );
112 Reference< XStyleFamiliesSupplier > xFamiliesSupp( xController->getModel(), UNO_QUERY_THROW );
113 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
114 const OUString sFamilyName( "table" );
115 mxTableFamily.set( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
117 catch (const Exception&)
119 OSL_FAIL( "sd::CustomAnimationPane::CustomAnimationPane(), Exception caught!" );
122 onSelectionChanged();
123 updateControls();
126 TableDesignWidget::~TableDesignWidget()
128 removeListener();
131 static SfxBindings* getBindings( ViewShellBase const & rBase )
133 if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() )
134 return &rBase.GetMainViewShell()->GetViewFrame()->GetBindings();
135 else
136 return nullptr;
139 static SfxDispatcher* getDispatcher( ViewShellBase const & rBase )
141 if( rBase.GetMainViewShell().get() && rBase.GetMainViewShell()->GetViewFrame() )
142 return rBase.GetMainViewShell()->GetViewFrame()->GetDispatcher();
143 else
144 return nullptr;
147 IMPL_LINK_NOARG(TableDesignWidget, implValueSetHdl, ValueSet*, void)
149 ApplyStyle();
152 void TableDesignWidget::ApplyStyle()
156 OUString sStyleName;
157 sal_Int32 nIndex = static_cast< sal_Int32 >( m_pValueSet->GetSelectedItemId() ) - 1;
159 if( (nIndex >= 0) && (nIndex < mxTableFamily->getCount()) )
161 Reference< XNameAccess > xNames( mxTableFamily, UNO_QUERY_THROW );
162 sStyleName = xNames->getElementNames()[nIndex];
165 if( sStyleName.isEmpty() )
166 return;
168 SdrView* pView = mrBase.GetDrawView();
169 if( mxSelectedTable.is() )
171 if( pView )
173 SfxRequest aReq( SID_TABLE_STYLE, SfxCallMode::SYNCHRON, SfxGetpApp()->GetPool() );
174 aReq.AppendItem( SfxStringItem( SID_TABLE_STYLE, sStyleName ) );
176 const rtl::Reference< sdr::SelectionController >& xController( pView->getSelectionController() );
177 if( xController.is() )
178 xController->Execute( aReq );
180 SfxBindings* pBindings = getBindings( mrBase );
181 if( pBindings )
183 pBindings->Invalidate( SID_UNDO );
184 pBindings->Invalidate( SID_REDO );
188 else
190 SfxDispatcher* pDispatcher = getDispatcher( mrBase );
191 SfxStringItem aArg( SID_TABLE_STYLE, sStyleName );
192 pDispatcher->ExecuteList(SID_INSERT_TABLE, SfxCallMode::ASYNCHRON,
193 { &aArg });
196 catch( Exception& )
198 OSL_FAIL("TableDesignWidget::implValueSetHdl(), exception caught!");
202 IMPL_LINK_NOARG(TableDesignWidget, implCheckBoxHdl, Button*, void)
204 ApplyOptions();
205 FillDesignPreviewControl();
208 void TableDesignWidget::ApplyOptions()
210 static const sal_uInt16 gParamIds[CB_COUNT] =
212 ID_VAL_USEFIRSTROWSTYLE, ID_VAL_USELASTROWSTYLE, ID_VAL_USEBANDINGROWSTYLE,
213 ID_VAL_USEFIRSTCOLUMNSTYLE, ID_VAL_USELASTCOLUMNSTYLE, ID_VAL_USEBANDINGCOLUMNSTYLE
216 if( !mxSelectedTable.is() )
217 return;
219 SfxRequest aReq( SID_TABLE_STYLE_SETTINGS, SfxCallMode::SYNCHRON, SfxGetpApp()->GetPool() );
221 for( sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i )
223 aReq.AppendItem( SfxBoolItem( gParamIds[i], m_aCheckBoxes[i]->IsChecked() ) );
226 SdrView* pView = mrBase.GetDrawView();
227 if( !pView )
228 return;
230 const rtl::Reference< sdr::SelectionController >& xController( pView->getSelectionController() );
231 if( xController.is() )
233 xController->Execute( aReq );
235 SfxBindings* pBindings = getBindings( mrBase );
236 if( pBindings )
238 pBindings->Invalidate( SID_UNDO );
239 pBindings->Invalidate( SID_REDO );
244 void TableDesignWidget::onSelectionChanged()
246 Reference< XPropertySet > xNewSelection;
248 if( mxView.is() ) try
250 Reference< XSelectionSupplier > xSel( mxView, UNO_QUERY_THROW );
251 Any aSel( xSel->getSelection() );
252 Sequence< XShape > xShapeSeq;
253 if( aSel >>= xShapeSeq )
255 if( xShapeSeq.getLength() == 1 )
256 aSel <<= xShapeSeq[0];
258 else
260 Reference< XShapes > xShapes( aSel, UNO_QUERY );
261 if( xShapes.is() && (xShapes->getCount() == 1) )
262 aSel = xShapes->getByIndex(0);
265 Reference< XShapeDescriptor > xDesc( aSel, UNO_QUERY );
266 if( xDesc.is() && ( xDesc->getShapeType() == "com.sun.star.drawing.TableShape" || xDesc->getShapeType() == "com.sun.star.presentation.TableShape" ) )
268 xNewSelection.set( xDesc, UNO_QUERY );
271 catch( Exception& )
273 OSL_FAIL( "sd::TableDesignWidget::onSelectionChanged(), Exception caught!" );
276 if( mxSelectedTable != xNewSelection )
278 mxSelectedTable = xNewSelection;
279 updateControls();
283 void TableValueSet::Resize()
285 ValueSet::Resize();
286 // Calculate the number of rows and columns.
287 if( GetItemCount() <= 0 )
288 return;
290 Size aValueSetSize = GetSizePixel();
292 Image aImage = GetItemImage(GetItemId(0));
293 Size aItemSize = aImage.GetSizePixel();
295 aItemSize.AdjustHeight(10 );
296 int nColumnCount = (aValueSetSize.Width() - GetScrollWidth()) / aItemSize.Width();
297 if (nColumnCount < 1)
298 nColumnCount = 1;
300 int nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount;
301 if (nRowCount < 1)
302 nRowCount = 1;
304 int nVisibleRowCount = (aValueSetSize.Height()+2) / aItemSize.Height();
306 SetColCount (static_cast<sal_uInt16>(nColumnCount));
307 SetLineCount (static_cast<sal_uInt16>(nRowCount));
309 if( !m_bModal )
311 WinBits nStyle = GetStyle() & ~WB_VSCROLL;
312 if( nRowCount > nVisibleRowCount )
314 nStyle |= WB_VSCROLL;
316 SetStyle( nStyle );
320 TableValueSet::TableValueSet(Window *pParent, WinBits nStyle)
321 : ValueSet(pParent, nStyle)
322 , m_bModal(false)
326 void TableValueSet::DataChanged( const DataChangedEvent& /*rDCEvt*/ )
328 updateSettings();
331 void TableValueSet::updateSettings()
333 if( !m_bModal )
335 SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
336 SetColor( GetSettings().GetStyleSettings().GetWindowColor() );
337 SetExtraSpacing(8);
341 VCL_BUILDER_FACTORY_CONSTRUCTOR(TableValueSet, WB_TABSTOP)
343 void TableDesignWidget::updateControls()
345 static const bool gDefaults[CB_COUNT] = { true, false, true, false, false, false };
347 const bool bHasTable = mxSelectedTable.is();
349 for (sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i)
351 bool bUse = gDefaults[i];
352 if( bHasTable ) try
354 mxSelectedTable->getPropertyValue( gPropNames[i] ) >>= bUse;
356 catch( Exception& )
358 OSL_FAIL("sd::TableDesignWidget::updateControls(), exception caught!");
360 m_aCheckBoxes[i]->Check(bUse);
361 m_aCheckBoxes[i]->Enable(bHasTable);
364 FillDesignPreviewControl();
365 m_pValueSet->updateSettings();
366 m_pValueSet->Resize();
368 sal_uInt16 nSelection = 0;
369 if( mxSelectedTable.is() )
371 Reference< XNamed > xNamed( mxSelectedTable->getPropertyValue( "TableTemplate" ), UNO_QUERY );
372 if( xNamed.is() )
374 const OUString sStyleName( xNamed->getName() );
376 Reference< XNameAccess > xNames( mxTableFamily, UNO_QUERY );
377 if( xNames.is() )
379 Sequence< OUString > aNames( xNames->getElementNames() );
380 for( sal_Int32 nIndex = 0; nIndex < aNames.getLength(); nIndex++ )
382 if( aNames[nIndex] == sStyleName )
384 nSelection = static_cast<sal_uInt16>(nIndex)+1;
385 break;
391 m_pValueSet->SelectItem( nSelection );
394 void TableDesignWidget::addListener()
396 Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this,TableDesignWidget,EventMultiplexerListener) );
397 mrBase.GetEventMultiplexer()->AddEventListener( aLink );
400 void TableDesignWidget::removeListener()
402 Link<tools::EventMultiplexerEvent&,void> aLink( LINK(this,TableDesignWidget,EventMultiplexerListener) );
403 mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
406 IMPL_LINK(TableDesignWidget,EventMultiplexerListener,
407 tools::EventMultiplexerEvent&, rEvent, void)
409 switch (rEvent.meEventId)
411 case EventMultiplexerEventId::CurrentPageChanged:
412 case EventMultiplexerEventId::EditViewSelection:
413 onSelectionChanged();
414 break;
416 case EventMultiplexerEventId::MainViewRemoved:
417 mxView.clear();
418 onSelectionChanged();
419 break;
421 case EventMultiplexerEventId::MainViewAdded:
422 mxView.set( mrBase.GetController(), UNO_QUERY );
423 onSelectionChanged();
424 break;
426 default: break;
430 struct CellInfo
432 Color maCellColor;
433 Color maTextColor;
434 std::shared_ptr<SvxBoxItem> maBorder;
436 explicit CellInfo( const Reference< XStyle >& xStyle );
439 CellInfo::CellInfo( const Reference< XStyle >& xStyle )
440 : maBorder(std::make_shared<SvxBoxItem>(SDRATTR_TABLE_BORDER))
442 SfxStyleSheet* pStyleSheet = SfxUnoStyleSheet::getUnoStyleSheet( xStyle );
443 if( !pStyleSheet )
444 return;
446 SfxItemSet& rSet = pStyleSheet->GetItemSet();
448 // get style fill color
449 if( !GetDraftFillColor(rSet, maCellColor) )
450 maCellColor = COL_TRANSPARENT;
452 // get style text color
453 const SvxColorItem* pTextColor = rSet.GetItem(EE_CHAR_COLOR);
454 if( pTextColor )
455 maTextColor = pTextColor->GetValue();
456 else
457 maTextColor = COL_TRANSPARENT;
459 // get border
460 const SvxBoxItem* pBoxItem = rSet.GetItem( SDRATTR_TABLE_BORDER );
461 if( pBoxItem )
462 maBorder.reset(static_cast<SvxBoxItem*>(pBoxItem->Clone()));
465 typedef std::vector< std::shared_ptr< CellInfo > > CellInfoVector;
466 typedef std::shared_ptr< CellInfo > CellInfoMatrix[nPreviewColumns * nPreviewRows];
468 struct TableStyleSettings
470 bool mbUseFirstRow;
471 bool mbUseLastRow;
472 bool mbUseFirstColumn;
473 bool mbUseLastColumn;
474 bool mbUseRowBanding;
475 bool mbUseColumnBanding;
477 TableStyleSettings()
478 : mbUseFirstRow(true)
479 , mbUseLastRow(false)
480 , mbUseFirstColumn(false)
481 , mbUseLastColumn(false)
482 , mbUseRowBanding(true)
483 , mbUseColumnBanding(false) {}
486 static void FillCellInfoVector( const Reference< XIndexAccess >& xTableStyle, CellInfoVector& rVector )
488 DBG_ASSERT( xTableStyle.is() && (xTableStyle->getCount() == sdr::table::style_count ), "sd::FillCellInfoVector(), invalid table style!" );
489 if( !xTableStyle.is() )
490 return;
494 rVector.resize( sdr::table::style_count );
496 for( sal_Int32 nStyle = 0; nStyle < sdr::table::style_count; ++nStyle )
498 Reference< XStyle > xStyle( xTableStyle->getByIndex( nStyle ), UNO_QUERY );
499 if( xStyle.is() )
500 rVector[nStyle].reset( new CellInfo( xStyle ) );
503 catch(Exception&)
505 OSL_FAIL("sd::FillCellInfoVector(), exception caught!");
509 static void FillCellInfoMatrix( const CellInfoVector& rStyle, const TableStyleSettings& rSettings, CellInfoMatrix& rMatrix )
511 for( sal_Int32 nRow = 0; nRow < nPreviewColumns; ++nRow )
513 const bool bFirstRow = rSettings.mbUseFirstRow && (nRow == 0);
514 const bool bLastRow = rSettings.mbUseLastRow && (nRow == nPreviewColumns - 1);
516 for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol )
518 std::shared_ptr< CellInfo > xCellInfo;
520 // first and last row win first, if used and available
521 if( bFirstRow )
523 xCellInfo = rStyle[sdr::table::first_row_style];
525 else if( bLastRow )
527 xCellInfo = rStyle[sdr::table::last_row_style];
530 if( !xCellInfo.get() )
532 // next come first and last column, if used and available
533 if( rSettings.mbUseFirstColumn && (nCol == 0) )
535 xCellInfo = rStyle[sdr::table::first_column_style];
537 else if( rSettings.mbUseLastColumn && (nCol == nPreviewColumns-1) )
539 xCellInfo = rStyle[sdr::table::last_column_style];
543 if( !xCellInfo.get() )
545 if( rSettings.mbUseRowBanding )
547 if( (nRow & 1) == 0 )
549 xCellInfo = rStyle[sdr::table::even_rows_style];
551 else
553 xCellInfo = rStyle[sdr::table::odd_rows_style];
558 if( !xCellInfo.get() )
560 if( rSettings.mbUseColumnBanding )
562 if( (nCol & 1) == 0 )
564 xCellInfo = rStyle[sdr::table::even_columns_style];
566 else
568 xCellInfo = rStyle[sdr::table::odd_columns_style];
573 if( !xCellInfo.get() )
575 // use default cell style if non found yet
576 xCellInfo = rStyle[sdr::table::body_style];
579 rMatrix[(nCol * nPreviewColumns) + nRow] = xCellInfo;
584 static const BitmapEx CreateDesignPreview( const Reference< XIndexAccess >& xTableStyle, const TableStyleSettings& rSettings, bool bIsPageDark )
586 CellInfoVector aCellInfoVector(sdr::table::style_count);
587 FillCellInfoVector( xTableStyle, aCellInfoVector );
589 CellInfoMatrix aMatrix;
590 FillCellInfoMatrix( aCellInfoVector, rSettings, aMatrix );
592 // bbbbbbbbbbbb w = 12 pixel
593 // bccccccccccb h = 7 pixel
594 // bccccccccccb b = border color
595 // bcttttttttcb c = cell color
596 // bccccccccccb t = text color
597 // bccccccccccb
598 // bbbbbbbbbbbb
600 ScopedVclPtr<VirtualDevice> pVirDev(VclPtr<VirtualDevice>::Create());
601 Size aBmpSize(nBitmapWidth, nBitmapHeight);
602 pVirDev->SetOutputSizePixel(aBmpSize);
604 pVirDev->SetBackground( bIsPageDark ? COL_BLACK : COL_WHITE );
605 pVirDev->Erase();
607 // first draw cell background and text line previews
608 sal_Int32 nY = 0;
609 sal_Int32 nRow;
610 for( nRow = 0; nRow < nPreviewRows; ++nRow, nY += nCellHeight-1 )
612 sal_Int32 nX = 0;
613 for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol, nX += nCellWidth-1 )
615 std::shared_ptr< CellInfo > xCellInfo(aMatrix[(nCol * nPreviewColumns) + nRow]);
617 Color aTextColor( COL_AUTO );
618 if( xCellInfo.get() )
620 // fill cell background
621 const ::tools::Rectangle aRect( nX, nY, nX + nCellWidth - 1, nY + nCellHeight - 1 );
623 if( xCellInfo->maCellColor != COL_TRANSPARENT )
625 pVirDev->SetFillColor( xCellInfo->maCellColor );
626 pVirDev->DrawRect( aRect );
629 aTextColor = xCellInfo->maTextColor;
632 // draw text preview line
633 if( aTextColor == COL_AUTO )
634 aTextColor = bIsPageDark ? COL_WHITE : COL_BLACK;
635 pVirDev->SetLineColor( aTextColor );
636 const Point aPnt1( nX + 2, nY + ((nCellHeight - 1 ) >> 1) );
637 const Point aPnt2( nX + nCellWidth - 3, aPnt1.Y() );
638 pVirDev->DrawLine( aPnt1, aPnt2 );
642 // second draw border lines
643 nY = 0;
644 for( nRow = 0; nRow < nPreviewRows; ++nRow, nY += nCellHeight-1 )
646 sal_Int32 nX = 0;
647 for( sal_Int32 nCol = 0; nCol < nPreviewColumns; ++nCol, nX += nCellWidth-1 )
649 std::shared_ptr< CellInfo > xCellInfo(aMatrix[(nCol * nPreviewColumns) + nRow]);
651 if( xCellInfo.get() )
653 const Point aPntTL( nX, nY );
654 const Point aPntTR( nX + nCellWidth - 1, nY );
655 const Point aPntBL( nX, nY + nCellHeight - 1 );
656 const Point aPntBR( nX + nCellWidth - 1, nY + nCellHeight - 1 );
658 sal_Int32 border_diffs[8] = { 0,-1, 0,1, -1,0, 1,0 };
659 sal_Int32* pDiff = &border_diffs[0];
661 // draw top border
662 for( SvxBoxItemLine nLine : o3tl::enumrange<SvxBoxItemLine>() )
664 const ::editeng::SvxBorderLine* pBorderLine = xCellInfo->maBorder->GetLine(nLine);
665 if( !pBorderLine || ((pBorderLine->GetOutWidth() == 0) && (pBorderLine->GetInWidth()==0)) )
666 continue;
668 sal_Int32 nBorderCol = nCol + *pDiff++;
669 sal_Int32 nBorderRow = nRow + *pDiff++;
670 if( (nBorderCol >= 0) && (nBorderCol < nPreviewColumns) && (nBorderRow >= 0) && (nBorderRow < nPreviewRows) )
672 // check border
673 std::shared_ptr< CellInfo > xBorderInfo(aMatrix[(nBorderCol * nPreviewColumns) + nBorderRow]);
674 if( xBorderInfo.get() )
676 const ::editeng::SvxBorderLine* pBorderLine2 = xBorderInfo->maBorder->GetLine(static_cast<SvxBoxItemLine>(static_cast<int>(nLine)^1));
677 if( pBorderLine2 && pBorderLine2->HasPriority(*pBorderLine) )
678 continue; // other border line wins
682 pVirDev->SetLineColor( pBorderLine->GetColor() );
683 switch( nLine )
685 case SvxBoxItemLine::TOP: pVirDev->DrawLine( aPntTL, aPntTR ); break;
686 case SvxBoxItemLine::BOTTOM: pVirDev->DrawLine( aPntBL, aPntBR ); break;
687 case SvxBoxItemLine::LEFT: pVirDev->DrawLine( aPntTL, aPntBL ); break;
688 case SvxBoxItemLine::RIGHT: pVirDev->DrawLine( aPntTR, aPntBR ); break;
695 return pVirDev->GetBitmapEx(Point(0,0), aBmpSize);
698 void TableDesignWidget::FillDesignPreviewControl()
700 sal_uInt16 nSelectedItem = m_pValueSet->GetSelectedItemId();
701 m_pValueSet->Clear();
704 TableStyleSettings aSettings;
705 if( mxSelectedTable.is() )
707 aSettings.mbUseFirstRow = m_aCheckBoxes[CB_HEADER_ROW]->IsChecked();
708 aSettings.mbUseLastRow = m_aCheckBoxes[CB_TOTAL_ROW]->IsChecked();
709 aSettings.mbUseRowBanding = m_aCheckBoxes[CB_BANDED_ROWS]->IsChecked();
710 aSettings.mbUseFirstColumn = m_aCheckBoxes[CB_FIRST_COLUMN]->IsChecked();
711 aSettings.mbUseLastColumn = m_aCheckBoxes[CB_LAST_COLUMN]->IsChecked();
712 aSettings.mbUseColumnBanding = m_aCheckBoxes[CB_BANDED_COLUMNS]->IsChecked();
715 bool bIsPageDark = false;
716 if( mxView.is() )
718 Reference< XPropertySet > xPageSet( mxView->getCurrentPage(), UNO_QUERY );
719 if( xPageSet.is() )
721 const OUString sIsBackgroundDark( "IsBackgroundDark" );
722 xPageSet->getPropertyValue(sIsBackgroundDark) >>= bIsPageDark;
726 sal_Int32 nCount = mxTableFamily->getCount();
727 for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex ) try
729 Reference< XIndexAccess > xTableStyle( mxTableFamily->getByIndex( nIndex ), UNO_QUERY );
730 if( xTableStyle.is() )
731 m_pValueSet->InsertItem( sal::static_int_cast<sal_uInt16>( nIndex + 1 ), Image( CreateDesignPreview( xTableStyle, aSettings, bIsPageDark ) ) );
733 catch( Exception& )
735 OSL_FAIL("sd::TableDesignWidget::FillDesignPreviewControl(), exception caught!");
737 sal_Int32 nCols = 3;
738 sal_Int32 nRows = (nCount+2)/3;
739 m_pValueSet->SetColCount(nCols);
740 m_pValueSet->SetLineCount(nRows);
741 WinBits nStyle = m_pValueSet->GetStyle() & ~WB_VSCROLL;
742 m_pValueSet->SetStyle(nStyle);
743 Size aSize(m_pValueSet->GetOptimalSize());
744 aSize.AdjustWidth(10 * nCols);
745 aSize.AdjustHeight(10 * nRows);
746 m_pValueSet->set_width_request(aSize.Width());
747 m_pValueSet->set_height_request(aSize.Height());
748 m_pValueSet->Resize();
750 catch( Exception& )
752 OSL_FAIL("sd::TableDesignWidget::FillDesignPreviewControl(), exception caught!");
754 m_pValueSet->SelectItem(nSelectedItem);
757 VclPtr<vcl::Window> createTableDesignPanel( vcl::Window* pParent, ViewShellBase& rBase )
759 VclPtr<TableDesignPane> pRet = nullptr;
762 pRet = VclPtr<TableDesignPane>::Create( pParent, rBase );
764 catch (const uno::Exception&)
767 return pRet;
772 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */