loplugin:flatten in sd

Change-Id: I57cf26d800d8d414014b88c250ee1cbd47551bc4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100007
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-08-03 15:52:33 +02:00
parent ece7781530
commit 186c34af5d
11 changed files with 543 additions and 544 deletions

View File

@@ -916,19 +916,19 @@ void CustomAnimationList::append( CustomAnimationEffectPtr pEffect )
static void selectShape(weld::TreeView* pTreeList, const Reference< XShape >& xShape ) static void selectShape(weld::TreeView* pTreeList, const Reference< XShape >& xShape )
{ {
std::unique_ptr<weld::TreeIter> xEntry = pTreeList->make_iterator(); std::unique_ptr<weld::TreeIter> xEntry = pTreeList->make_iterator();
if (pTreeList->get_iter_first(*xEntry)) if (!pTreeList->get_iter_first(*xEntry))
return;
do
{ {
do CustomAnimationListEntryItem* pEntry = reinterpret_cast<CustomAnimationListEntryItem*>(pTreeList->get_id(*xEntry).toInt64());
CustomAnimationEffectPtr pEffect(pEntry->getEffect());
if (pEffect)
{ {
CustomAnimationListEntryItem* pEntry = reinterpret_cast<CustomAnimationListEntryItem*>(pTreeList->get_id(*xEntry).toInt64()); if (pEffect->getTarget() == xShape)
CustomAnimationEffectPtr pEffect(pEntry->getEffect()); pTreeList->select(*xEntry);
if (pEffect) }
{ } while (pTreeList->iter_next(*xEntry));
if (pEffect->getTarget() == xShape)
pTreeList->select(*xEntry);
}
} while (pTreeList->iter_next(*xEntry));
}
} }
void CustomAnimationList::onSelectionChanged(const Any& rSelection) void CustomAnimationList::onSelectionChanged(const Any& rSelection)

View File

@@ -141,101 +141,101 @@ SdTransferable::~SdTransferable()
void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
{ {
if( pObj ) if( !pObj )
return;
mpOLEDataHelper.reset();
mpGraphic.reset();
mpBookmark.reset();
mpImageMap.reset();
if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
{ {
mpOLEDataHelper.reset(); try
mpGraphic.reset();
mpBookmark.reset();
mpImageMap.reset();
if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
{ {
try uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef();
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
{ {
uno::Reference < embed::XEmbeddedObject > xObj = static_cast< SdrOle2Obj* >( pObj )->GetObjRef(); mpOLEDataHelper.reset( new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) ) );
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
{
mpOLEDataHelper.reset( new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) ) );
// TODO/LATER: the standalone handling of the graphic should not be used any more in future // TODO/LATER: the standalone handling of the graphic should not be used any more in future
// The EmbedDataHelper should bring the graphic in future // The EmbedDataHelper should bring the graphic in future
const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic(); const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
if ( pObjGr ) if ( pObjGr )
mpGraphic.reset( new Graphic( *pObjGr ) ); mpGraphic.reset( new Graphic( *pObjGr ) );
}
}
catch( uno::Exception& )
{}
}
else if( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && (mpSourceDoc && !SdDrawDocument::GetAnimationInfo( pObj )) )
{
mpGraphic.reset( new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() ) );
}
else if( pObj->IsUnoObj() && SdrInventor::FmForm == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == sal_uInt16(OBJ_FM_BUTTON) ) )
{
SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
if (SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
{
const Reference< css::awt::XControlModel >& xControlModel( pUnoCtrl->GetUnoControlModel() );
if( !xControlModel.is() )
return;
Reference< css::beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
if( !xPropSet.is() )
return;
css::form::FormButtonType eButtonType;
Any aTmp( xPropSet->getPropertyValue( "ButtonType" ) );
if( aTmp >>= eButtonType )
{
OUString aLabel, aURL;
xPropSet->getPropertyValue( "Label" ) >>= aLabel;
xPropSet->getPropertyValue( "TargetURL" ) >>= aURL;
mpBookmark.reset( new INetBookmark( aURL, aLabel ) );
}
} }
} }
else if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr ) catch( uno::Exception& )
{}
}
else if( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && (mpSourceDoc && !SdDrawDocument::GetAnimationInfo( pObj )) )
{
mpGraphic.reset( new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() ) );
}
else if( pObj->IsUnoObj() && SdrInventor::FmForm == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == sal_uInt16(OBJ_FM_BUTTON) ) )
{
SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pObj );
if (SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
{ {
const OutlinerParaObject* pPara; const Reference< css::awt::XControlModel >& xControlModel( pUnoCtrl->GetUnoControlModel() );
if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != nullptr ) if( !xControlModel.is() )
return;
Reference< css::beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY );
if( !xPropSet.is() )
return;
css::form::FormButtonType eButtonType;
Any aTmp( xPropSet->getPropertyValue( "ButtonType" ) );
if( aTmp >>= eButtonType )
{ {
const SvxFieldItem* pField; OUString aLabel, aURL;
if( (pField = pPara->GetTextObject().GetField()) != nullptr ) xPropSet->getPropertyValue( "Label" ) >>= aLabel;
xPropSet->getPropertyValue( "TargetURL" ) >>= aURL;
mpBookmark.reset( new INetBookmark( aURL, aLabel ) );
}
}
}
else if( dynamic_cast< const SdrTextObj *>( pObj ) != nullptr )
{
const OutlinerParaObject* pPara;
if( (pPara = static_cast< SdrTextObj* >( pObj )->GetOutlinerParaObject()) != nullptr )
{
const SvxFieldItem* pField;
if( (pField = pPara->GetTextObject().GetField()) != nullptr )
{
const SvxFieldData* pData = pField->GetField();
if( auto pURL = dynamic_cast< const SvxURLField *>( pData ) )
{ {
const SvxFieldData* pData = pField->GetField(); // #i63399# This special code identifies TextFrames which have just a URL
// as content and directly add this to the clipboard, probably to avoid adding
if( auto pURL = dynamic_cast< const SvxURLField *>( pData ) ) // an unnecessary DrawObject to the target where paste may take place. This is
// wanted only for SdrObjects with no fill and no line, else it is necessary to
// use the whole SdrObect. Test here for Line/FillStyle and take shortcut only
// when both are unused
if(!pObj->HasFillStyle() && !pObj->HasLineStyle())
{ {
// #i63399# This special code identifies TextFrames which have just a URL mpBookmark.reset( new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() ) );
// as content and directly add this to the clipboard, probably to avoid adding
// an unnecessary DrawObject to the target where paste may take place. This is
// wanted only for SdrObjects with no fill and no line, else it is necessary to
// use the whole SdrObect. Test here for Line/FillStyle and take shortcut only
// when both are unused
if(!pObj->HasFillStyle() && !pObj->HasLineStyle())
{
mpBookmark.reset( new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() ) );
}
} }
} }
} }
} }
SvxIMapInfo* pInfo = SvxIMapInfo::GetIMapInfo( pObj );
if( pInfo )
mpImageMap.reset( new ImageMap( pInfo->GetImageMap() ) );
} }
SvxIMapInfo* pInfo = SvxIMapInfo::GetIMapInfo( pObj );
if( pInfo )
mpImageMap.reset( new ImageMap( pInfo->GetImageMap() ) );
} }
void SdTransferable::CreateData() void SdTransferable::CreateData()
@@ -301,32 +301,32 @@ void SdTransferable::CreateData()
} }
// set VisArea and adjust objects if necessary // set VisArea and adjust objects if necessary
if( maVisArea.IsEmpty() && if( !(maVisArea.IsEmpty() &&
mpSdDrawDocumentIntern && mpSdViewIntern && mpSdDrawDocumentIntern && mpSdViewIntern &&
mpSdDrawDocumentIntern->GetPageCount() ) mpSdDrawDocumentIntern->GetPageCount()) )
return;
SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PageKind::Standard );
if( 1 == mpSdDrawDocumentIntern->GetPageCount() )
{ {
SdPage* pPage = mpSdDrawDocumentIntern->GetSdPage( 0, PageKind::Standard ); // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
// fat lines correctly
maVisArea = mpSdViewIntern->GetAllMarkedBoundRect();
Point aOrigin( maVisArea.TopLeft() );
Size aVector( -aOrigin.X(), -aOrigin.Y() );
if( 1 == mpSdDrawDocumentIntern->GetPageCount() ) for( size_t nObj = 0, nObjCount = pPage->GetObjCount(); nObj < nObjCount; ++nObj )
{ {
// #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get SdrObject* pObj = pPage->GetObj( nObj );
// fat lines correctly pObj->NbcMove( aVector );
maVisArea = mpSdViewIntern->GetAllMarkedBoundRect();
Point aOrigin( maVisArea.TopLeft() );
Size aVector( -aOrigin.X(), -aOrigin.Y() );
for( size_t nObj = 0, nObjCount = pPage->GetObjCount(); nObj < nObjCount; ++nObj )
{
SdrObject* pObj = pPage->GetObj( nObj );
pObj->NbcMove( aVector );
}
} }
else
maVisArea.SetSize( pPage->GetSize() );
// output is at the zero point
maVisArea.SetPos( Point() );
} }
else
maVisArea.SetSize( pPage->GetSize() );
// output is at the zero point
maVisArea.SetPos( Point() );
} }
static bool lcl_HasOnlyControls( SdrModel* pModel ) static bool lcl_HasOnlyControls( SdrModel* pModel )
@@ -375,68 +375,68 @@ static bool lcl_HasOnlyOneTable( SdrModel* pModel )
void SdTransferable::AddSupportedFormats() void SdTransferable::AddSupportedFormats()
{ {
if( !mbPageTransferable || mbPageTransferablePersistent ) if( !(!mbPageTransferable || mbPageTransferablePersistent) )
return;
if( !mbLateInit )
CreateData();
if( mpObjDesc )
AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
if( mpOLEDataHelper )
{ {
if( !mbLateInit ) AddFormat( SotClipboardFormatId::EMBED_SOURCE );
CreateData();
if( mpObjDesc ) DataFlavorExVector aVector( mpOLEDataHelper->GetDataFlavorExVector() );
AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR );
if( mpOLEDataHelper ) for( const auto& rItem : aVector )
AddFormat( rItem );
}
else if( mpGraphic )
{
// #i25616#
AddFormat( SotClipboardFormatId::DRAWING );
AddFormat( SotClipboardFormatId::SVXB );
if( mpGraphic->GetType() == GraphicType::Bitmap )
{ {
AddFormat( SotClipboardFormatId::EMBED_SOURCE ); AddFormat( SotClipboardFormatId::PNG );
AddFormat( SotClipboardFormatId::BITMAP );
DataFlavorExVector aVector( mpOLEDataHelper->GetDataFlavorExVector() ); AddFormat( SotClipboardFormatId::GDIMETAFILE );
for( const auto& rItem : aVector )
AddFormat( rItem );
}
else if( mpGraphic )
{
// #i25616#
AddFormat( SotClipboardFormatId::DRAWING );
AddFormat( SotClipboardFormatId::SVXB );
if( mpGraphic->GetType() == GraphicType::Bitmap )
{
AddFormat( SotClipboardFormatId::PNG );
AddFormat( SotClipboardFormatId::BITMAP );
AddFormat( SotClipboardFormatId::GDIMETAFILE );
}
else
{
AddFormat( SotClipboardFormatId::GDIMETAFILE );
AddFormat( SotClipboardFormatId::PNG );
AddFormat( SotClipboardFormatId::BITMAP );
}
}
else if( mpBookmark )
{
AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
AddFormat( SotClipboardFormatId::STRING );
} }
else else
{ {
AddFormat( SotClipboardFormatId::EMBED_SOURCE ); AddFormat( SotClipboardFormatId::GDIMETAFILE );
AddFormat( SotClipboardFormatId::DRAWING ); AddFormat( SotClipboardFormatId::PNG );
if( !mpSdDrawDocument || !lcl_HasOnlyControls( mpSdDrawDocument ) ) AddFormat( SotClipboardFormatId::BITMAP );
{ }
AddFormat( SotClipboardFormatId::GDIMETAFILE ); }
AddFormat( SotClipboardFormatId::PNG ); else if( mpBookmark )
AddFormat( SotClipboardFormatId::BITMAP ); {
} AddFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK );
AddFormat( SotClipboardFormatId::STRING );
if( lcl_HasOnlyOneTable( mpSdDrawDocument ) ) { }
AddFormat( SotClipboardFormatId::RTF ); else
AddFormat( SotClipboardFormatId::RICHTEXT ); {
} AddFormat( SotClipboardFormatId::EMBED_SOURCE );
AddFormat( SotClipboardFormatId::DRAWING );
if( !mpSdDrawDocument || !lcl_HasOnlyControls( mpSdDrawDocument ) )
{
AddFormat( SotClipboardFormatId::GDIMETAFILE );
AddFormat( SotClipboardFormatId::PNG );
AddFormat( SotClipboardFormatId::BITMAP );
} }
if( mpImageMap ) if( lcl_HasOnlyOneTable( mpSdDrawDocument ) ) {
AddFormat( SotClipboardFormatId::SVIM ); AddFormat( SotClipboardFormatId::RTF );
AddFormat( SotClipboardFormatId::RICHTEXT );
}
} }
if( mpImageMap )
AddFormat( SotClipboardFormatId::SVIM );
} }
bool SdTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDoc ) bool SdTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDoc )
@@ -666,44 +666,44 @@ void SdTransferable::SetObjectDescriptor( std::unique_ptr<TransferableObjectDesc
void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmarks, bool bPersistent ) void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmarks, bool bPersistent )
{ {
if( mpSourceDoc ) if( !mpSourceDoc )
return;
if( mpSdViewIntern )
mpSdViewIntern->HideSdrPage();
mpSdDrawDocument->ClearModel(false);
mpPageDocShell = nullptr;
maPageBookmarks.clear();
if( bPersistent )
{ {
if( mpSdViewIntern ) mpSdDrawDocument->CreateFirstPages(mpSourceDoc);
mpSdViewIntern->HideSdrPage(); mpSdDrawDocument->InsertBookmarkAsPage( rPageBookmarks, nullptr, false, true, 1, true,
mpSourceDoc->GetDocSh(), true, true, false );
mpSdDrawDocument->ClearModel(false);
mpPageDocShell = nullptr;
maPageBookmarks.clear();
if( bPersistent )
{
mpSdDrawDocument->CreateFirstPages(mpSourceDoc);
mpSdDrawDocument->InsertBookmarkAsPage( rPageBookmarks, nullptr, false, true, 1, true,
mpSourceDoc->GetDocSh(), true, true, false );
}
else
{
mpPageDocShell = mpSourceDoc->GetDocSh();
maPageBookmarks = rPageBookmarks;
}
if( mpSdViewIntern )
{
SdPage* pPage = mpSdDrawDocument->GetSdPage( 0, PageKind::Standard );
if( pPage )
{
mpSdViewIntern->MarkAllObj( mpSdViewIntern->ShowSdrPage( pPage ) );
}
}
// set flags for page transferable; if ( mbPageTransferablePersistent == sal_False ),
// don't offer any formats => it's just for internal purposes
mbPageTransferable = true;
mbPageTransferablePersistent = bPersistent;
} }
else
{
mpPageDocShell = mpSourceDoc->GetDocSh();
maPageBookmarks = rPageBookmarks;
}
if( mpSdViewIntern )
{
SdPage* pPage = mpSdDrawDocument->GetSdPage( 0, PageKind::Standard );
if( pPage )
{
mpSdViewIntern->MarkAllObj( mpSdViewIntern->ShowSdrPage( pPage ) );
}
}
// set flags for page transferable; if ( mbPageTransferablePersistent == sal_False ),
// don't offer any formats => it's just for internal purposes
mbPageTransferable = true;
mbPageTransferablePersistent = bPersistent;
} }
sal_Int64 SAL_CALL SdTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) sal_Int64 SAL_CALL SdTransferable::getSomething( const css::uno::Sequence< sal_Int8 >& rId )

View File

@@ -217,34 +217,34 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg
mxFrame2->show(); mxFrame2->show();
} }
if( eMode == DrawViewMode_DRAW ) if( eMode != DrawViewMode_DRAW )
return;
if( !mxFrame.is() )
return;
OUString sSlotStr;
if( bInsertPage )
sSlotStr = ".uno:DuplicatePage";
else
sSlotStr = ".uno:Undo";
css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, mxFrame);
OUString sSlotTitle;
if( bInsertPage )
{ {
if( mxFrame.is() ) auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sSlotStr, mxControl->getModuleName());
{ sSlotTitle = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
OUString sSlotStr;
if( bInsertPage )
sSlotStr = ".uno:DuplicatePage";
else
sSlotStr = ".uno:Undo";
css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, mxFrame);
OUString sSlotTitle;
if( bInsertPage )
{
auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(sSlotStr, mxControl->getModuleName());
sSlotTitle = vcl::CommandInfoProvider::GetLabelForCommand(aProperties);
}
else
sSlotTitle = SdResId( STR_RESET_LAYOUT );
mxMoreButton->set_label(sSlotTitle);
mxMoreButton->set_image(xSlotImage);
mxMoreButton->connect_clicked(LINK(this, LayoutToolbarMenu, SelectToolbarMenuHdl));
mxMoreButton->show();
}
} }
else
sSlotTitle = SdResId( STR_RESET_LAYOUT );
mxMoreButton->set_label(sSlotTitle);
mxMoreButton->set_image(xSlotImage);
mxMoreButton->connect_clicked(LINK(this, LayoutToolbarMenu, SelectToolbarMenuHdl));
mxMoreButton->show();
} }
IMPL_LINK(LayoutToolbarMenu, SelectValueSetHdl, ValueSet*, pLayoutSet, void) IMPL_LINK(LayoutToolbarMenu, SelectValueSetHdl, ValueSet*, pLayoutSet, void)

View File

@@ -821,97 +821,96 @@ IMPL_LINK(SvxBulletAndPositionDlg, GraphicHdl_Impl, const OString&, rIdent, void
} }
} }
} }
if (bSucc) if (!bSucc)
return;
aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit));
sal_uInt16 nMask = 1;
for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
{ {
aSize = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(eCoreUnit)); if (nActNumLvl & nMask)
sal_uInt16 nMask = 1;
for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
{ {
if (nActNumLvl & nMask) SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
{ aNumFmt.SetCharFormatName(m_sNumCharFmtName);
SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); aNumFmt.SetGraphic(aGrfName);
aNumFmt.SetCharFormatName(m_sNumCharFmtName);
aNumFmt.SetGraphic(aGrfName);
// set size for a later comparison // set size for a later comparison
const SvxBrushItem* pBrushItem = aNumFmt.GetBrush(); const SvxBrushItem* pBrushItem = aNumFmt.GetBrush();
// initiate asynchronous loading // initiate asynchronous loading
sal_Int16 eOrient = aNumFmt.GetVertOrient(); sal_Int16 eOrient = aNumFmt.GetVertOrient();
aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient); aNumFmt.SetGraphicBrush(pBrushItem, &aSize, &eOrient);
aInitSize[i] = aNumFmt.GetGraphicSize(); aInitSize[i] = aNumFmt.GetGraphicSize();
pActNum->SetLevel(i, aNumFmt); pActNum->SetLevel(i, aNumFmt);
}
nMask <<= 1;
} }
m_xRatioCB->set_sensitive(true); nMask <<= 1;
m_xWidthFT->set_sensitive(true);
m_xHeightFT->set_sensitive(true);
m_xWidthMF->set_sensitive(true);
m_xHeightMF->set_sensitive(true);
SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit);
SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit);
SetModified();
//needed due to asynchronous loading of graphics in the SvxBrushItem
aInvalidateTimer.Start();
} }
m_xRatioCB->set_sensitive(true);
m_xWidthFT->set_sensitive(true);
m_xHeightFT->set_sensitive(true);
m_xWidthMF->set_sensitive(true);
m_xHeightMF->set_sensitive(true);
SetMetricValue(*m_xWidthMF, aSize.Width(), eCoreUnit);
SetMetricValue(*m_xHeightMF, aSize.Height(), eCoreUnit);
SetModified();
//needed due to asynchronous loading of graphics in the SvxBrushItem
aInvalidateTimer.Start();
} }
IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PopupActivateHdl_Impl, weld::ToggleButton&, void) IMPL_LINK_NOARG(SvxBulletAndPositionDlg, PopupActivateHdl_Impl, weld::ToggleButton&, void)
{ {
if (!m_xGalleryMenu) if (m_xGalleryMenu)
return;
m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu");
weld::WaitObject aWait(p_Window);
if (!GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames))
return;
GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
Graphic aGraphic;
OUString sGrfName;
ScopedVclPtrInstance<VirtualDevice> pVD;
size_t i = 0;
for (const auto& grfName : aGrfNames)
{ {
m_xGalleryMenu = m_xBuilder->weld_menu("gallerysubmenu"); sGrfName = grfName;
weld::WaitObject aWait(p_Window); OUString sItemId = "gallery" + OUString::number(i);
INetURLObject aObj(sGrfName);
if (GalleryExplorer::FillObjList(GALLERY_THEME_BULLETS, aGrfNames)) if (aObj.GetProtocol() == INetProtocol::File)
sGrfName = aObj.PathToFileName();
if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, i, &aGraphic))
{ {
GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS); BitmapEx aBitmap(aGraphic.GetBitmapEx());
Size aSize(aBitmap.GetSizePixel());
Graphic aGraphic; if (aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
OUString sGrfName;
ScopedVclPtrInstance<VirtualDevice> pVD;
size_t i = 0;
for (const auto& grfName : aGrfNames)
{ {
sGrfName = grfName; bool bWidth = aSize.Width() > aSize.Height();
OUString sItemId = "gallery" + OUString::number(i); double nScale = bWidth
INetURLObject aObj(sGrfName); ? double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width())
if (aObj.GetProtocol() == INetProtocol::File) : double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
sGrfName = aObj.PathToFileName(); aBitmap.Scale(nScale, nScale);
if (GalleryExplorer::GetGraphicObj(GALLERY_THEME_BULLETS, i, &aGraphic))
{
BitmapEx aBitmap(aGraphic.GetBitmapEx());
Size aSize(aBitmap.GetSizePixel());
if (aSize.Width() > MAX_BMP_WIDTH || aSize.Height() > MAX_BMP_HEIGHT)
{
bool bWidth = aSize.Width() > aSize.Height();
double nScale
= bWidth ? double(MAX_BMP_WIDTH) / static_cast<double>(aSize.Width())
: double(MAX_BMP_HEIGHT) / static_cast<double>(aSize.Height());
aBitmap.Scale(nScale, nScale);
}
pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false);
pVD->DrawBitmapEx(Point(), aBitmap);
// We want to show only icon names not full path.
aObj.removeExtension();
OUString sIconName
= aObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset);
m_xGalleryMenu->append(sItemId, sIconName, *pVD);
}
else
{
m_xGalleryMenu->append(sItemId, sGrfName);
}
++i;
} }
GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS); pVD->SetOutputSizePixel(aBitmap.GetSizePixel(), false);
pVD->DrawBitmapEx(Point(), aBitmap);
// We want to show only icon names not full path.
aObj.removeExtension();
OUString sIconName = aObj.GetLastName(INetURLObject::DecodeMechanism::WithCharset);
m_xGalleryMenu->append(sItemId, sIconName, *pVD);
} }
else
{
m_xGalleryMenu->append(sItemId, sGrfName);
}
++i;
} }
GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
} }
IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void) IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void)
@@ -950,26 +949,26 @@ IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void)
aMap.SetCharFont(aActBulletFont); aMap.SetCharFont(aActBulletFont);
if (bSameBullet) if (bSameBullet)
aMap.SetChar(cBullet); aMap.SetChar(cBullet);
if (aMap.run() == RET_OK) if (aMap.run() != RET_OK)
return;
// change Font Numrules
aActBulletFont = aMap.GetCharFont();
sal_uInt16 _nMask = 1;
for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
{ {
// change Font Numrules if (nActNumLvl & _nMask)
aActBulletFont = aMap.GetCharFont();
sal_uInt16 _nMask = 1;
for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
{ {
if (nActNumLvl & _nMask) SvxNumberFormat aNumFmt(pActNum->GetLevel(i));
{ aNumFmt.SetBulletFont(&aActBulletFont);
SvxNumberFormat aNumFmt(pActNum->GetLevel(i)); aNumFmt.SetBulletChar(static_cast<sal_Unicode>(aMap.GetChar()));
aNumFmt.SetBulletFont(&aActBulletFont); pActNum->SetLevel(i, aNumFmt);
aNumFmt.SetBulletChar(static_cast<sal_Unicode>(aMap.GetChar()));
pActNum->SetLevel(i, aNumFmt);
}
_nMask <<= 1;
} }
_nMask <<= 1;
SetModified();
} }
SetModified();
} }
IMPL_LINK(SvxBulletAndPositionDlg, SizeHdl_Impl, weld::MetricSpinButton&, rField, void) IMPL_LINK(SvxBulletAndPositionDlg, SizeHdl_Impl, weld::MetricSpinButton&, rField, void)

View File

@@ -358,22 +358,22 @@ IMPL_LINK(SdNavigatorWin, MenuSelectHdl, const OString&, rIdent, void)
sal_uInt32 nMenuId = rIdent.toUInt32(); sal_uInt32 nMenuId = rIdent.toUInt32();
NavigatorDragType eDT = static_cast<NavigatorDragType>(nMenuId); NavigatorDragType eDT = static_cast<NavigatorDragType>(nMenuId);
if( meDragType != eDT ) if( meDragType == eDT )
return;
meDragType = eDT;
SetDragImage();
if( meDragType == NAVIGATOR_DRAGTYPE_URL )
{ {
meDragType = eDT; // patch, prevents endless loop
SetDragImage(); if (mxTlbObjects->count_selected_rows() > 1)
mxTlbObjects->unselect_all();
if( meDragType == NAVIGATOR_DRAGTYPE_URL ) mxTlbObjects->set_selection_mode(SelectionMode::Single);
{
// patch, prevents endless loop
if (mxTlbObjects->count_selected_rows() > 1)
mxTlbObjects->unselect_all();
mxTlbObjects->set_selection_mode(SelectionMode::Single);
}
else
mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
} }
else
mxTlbObjects->set_selection_mode(SelectionMode::Multiple);
} }
IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, const OString&, rIdent, void ) IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, const OString&, rIdent, void )
@@ -390,19 +390,19 @@ IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, const OString&, rIdent, void )
// Remember the selection in the FrameView. // Remember the selection in the FrameView.
NavDocInfo* pInfo = GetDocInfo(); NavDocInfo* pInfo = GetDocInfo();
if (pInfo != nullptr) if (pInfo == nullptr)
return;
::sd::DrawDocShell* pDocShell = pInfo->mpDocShell;
if (pDocShell != nullptr)
{ {
::sd::DrawDocShell* pDocShell = pInfo->mpDocShell; ::sd::ViewShell* pViewShell = pDocShell->GetViewShell();
if (pDocShell != nullptr) if (pViewShell != nullptr)
{ {
::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); ::sd::FrameView* pFrameView = pViewShell->GetFrameView();
if (pViewShell != nullptr) if (pFrameView != nullptr)
{ {
::sd::FrameView* pFrameView = pViewShell->GetFrameView(); pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
if (pFrameView != nullptr)
{
pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes);
}
} }
} }
} }

View File

@@ -111,29 +111,29 @@ void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq )
if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) )
maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue();
if (nSlotId == SID_DRAW_FREELINE_NOFILL) if (nSlotId != SID_DRAW_FREELINE_NOFILL)
{ return;
const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3);
const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME);
if (pTransparence && pTransparence->GetValue() > 0) const SfxUInt16Item* pTransparence = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
{ const SfxStringItem* pColor = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
mnTransparence = pTransparence->GetValue(); const SfxUInt16Item* pWidth = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3);
} const SfxStringItem* pShapeName = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME);
if (pColor && !pColor->GetValue().isEmpty())
{ if (pTransparence && pTransparence->GetValue() > 0)
msColor = pColor->GetValue(); {
} mnTransparence = pTransparence->GetValue();
if (pWidth && pWidth->GetValue() > 0) }
{ if (pColor && !pColor->GetValue().isEmpty())
mnWidth = pWidth->GetValue(); {
} msColor = pColor->GetValue();
if (pShapeName && !pShapeName->GetValue().isEmpty()) }
{ if (pWidth && pWidth->GetValue() > 0)
msShapeName = pShapeName->GetValue(); {
} mnWidth = pWidth->GetValue();
}
if (pShapeName && !pShapeName->GetValue().isEmpty())
{
msShapeName = pShapeName->GetValue();
} }
} }

View File

@@ -172,18 +172,18 @@ IMPL_LINK(MasterPagesSelector, RightClickHandler, const MouseEvent&, rEvent, voi
mxPreviewValueSet->GrabFocus (); mxPreviewValueSet->GrabFocus ();
mxPreviewValueSet->ReleaseMouse(); mxPreviewValueSet->ReleaseMouse();
SfxViewFrame* pViewFrame = mrBase.GetViewFrame(); SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
if (pViewFrame != nullptr) if (pViewFrame == nullptr)
return;
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
if (pDispatcher != nullptr)
{ {
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); sal_uInt16 nIndex = mxPreviewValueSet->GetItemId (rEvent.GetPosPixel());
if (pDispatcher != nullptr) if (nIndex > 0)
{ {
sal_uInt16 nIndex = mxPreviewValueSet->GetItemId (rEvent.GetPosPixel()); mxPreviewValueSet->SelectItem (nIndex);
if (nIndex > 0) // Now do the actual display of the context menu
{ ShowContextMenu(&rEvent.GetPosPixel());
mxPreviewValueSet->SelectItem (nIndex);
// Now do the actual display of the context menu
ShowContextMenu(&rEvent.GetPosPixel());
}
} }
} }
} }
@@ -193,35 +193,35 @@ void MasterPagesSelector::ShowContextMenu(const Point* pPos)
// Use the currently selected item and show the popup menu in its // Use the currently selected item and show the popup menu in its
// center. // center.
const sal_uInt16 nIndex = mxPreviewValueSet->GetSelectedItemId(); const sal_uInt16 nIndex = mxPreviewValueSet->GetSelectedItemId();
if (nIndex > 0) if (nIndex <= 0)
return;
// The position of the upper left corner of the context menu is
// taken either from the mouse position (when the command was sent
// as reaction to a right click) or in the center of the selected
// item (when the command was sent as reaction to Shift+F10.)
Point aPosition;
if (!pPos)
{ {
// The position of the upper left corner of the context menu is ::tools::Rectangle aBBox (mxPreviewValueSet->GetItemRect(nIndex));
// taken either from the mouse position (when the command was sent aPosition = aBBox.Center();
// as reaction to a right click) or in the center of the selected
// item (when the command was sent as reaction to Shift+F10.)
Point aPosition;
if (!pPos)
{
::tools::Rectangle aBBox (mxPreviewValueSet->GetItemRect(nIndex));
aPosition = aBBox.Center();
}
else
aPosition = *pPos;
// Setup the menu.
VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), GetContextMenuUIFile(), "");
VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
if (pMenuWindow != nullptr)
pMenuWindow->SetPopupModeFlags(
pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected));
ProcessPopupMenu(*pMenu);
// Show the menu.
pMenu->Execute(this, ::tools::Rectangle(aPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
} }
else
aPosition = *pPos;
// Setup the menu.
VclBuilder aBuilder(nullptr, AllSettings::GetUIRootDir(), GetContextMenuUIFile(), "");
VclPtr<PopupMenu> pMenu(aBuilder.get_menu("menu"));
FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow());
if (pMenuWindow != nullptr)
pMenuWindow->SetPopupModeFlags(
pMenuWindow->GetPopupModeFlags() | FloatWinPopupFlags::NoMouseUpClose);
pMenu->SetSelectHdl(LINK(this, MasterPagesSelector, OnMenuItemSelected));
ProcessPopupMenu(*pMenu);
// Show the menu.
pMenu->Execute(this, ::tools::Rectangle(aPosition,Size(1,1)), PopupMenuFlags::ExecuteDown);
} }
void MasterPagesSelector::Command (const CommandEvent& rEvent) void MasterPagesSelector::Command (const CommandEvent& rEvent)

View File

@@ -1080,18 +1080,18 @@ IMPL_LINK_NOARG(SlideBackground, PaperSizeModifyHdl, weld::ComboBox&, void)
{ &aSizeItem, mpPageItem.get(), &aFitObjs }); { &aSizeItem, mpPageItem.get(), &aFitObjs });
// Notify LOK clients of the page size change. // Notify LOK clients of the page size change.
if (comphelper::LibreOfficeKit::isActive()) if (!comphelper::LibreOfficeKit::isActive())
return;
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{ {
SfxViewShell* pViewShell = SfxViewShell::GetFirst(); if (pViewShell->GetDocId() == mrBase.GetDocId())
while (pViewShell)
{ {
if (pViewShell->GetDocId() == mrBase.GetDocId()) SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
{ SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
SdXImpressDocument* pDoc = comphelper::getUnoTunnelImplementation<SdXImpressDocument>(pViewShell->GetCurrentDocument());
SfxLokHelper::notifyDocumentSizeChangedAllViews(pDoc);
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
} }
pViewShell = SfxViewShell::GetNext(*pViewShell);
} }
} }

View File

@@ -1613,33 +1613,33 @@ void SdOutliner::EnterEditMode (bool bGrabFocus)
// Make FuText the current function. // Make FuText the current function.
SfxUInt16Item aItem (SID_TEXTEDIT, 1); SfxUInt16Item aItem (SID_TEXTEDIT, 1);
std::shared_ptr<sd::ViewShell> pViewShell (mpWeakViewShell.lock()); std::shared_ptr<sd::ViewShell> pViewShell (mpWeakViewShell.lock());
if (pViewShell && pViewShell->GetDispatcher()) if (!(pViewShell && pViewShell->GetDispatcher()))
return;
pViewShell->GetDispatcher()->ExecuteList(
SID_TEXTEDIT, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, {&aItem});
if (mpView->IsTextEdit())
{ {
pViewShell->GetDispatcher()->ExecuteList( // end text edition before starting it again
SID_TEXTEDIT, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, {&aItem}); mpView->SdrEndTextEdit();
if (mpView->IsTextEdit())
{
// end text edition before starting it again
mpView->SdrEndTextEdit();
}
// To be consistent with the usual behaviour in the Office the text
// object that is put into edit mode would have also to be selected.
// Starting the text edit mode is not enough so we do it here by
// hand.
mpView->UnmarkAllObj(pPV);
mpView->MarkObj(mpSearchSpellTextObj, pPV);
mpSearchSpellTextObj->setActiveText(mnText);
// Turn on the edit mode for the text object.
mpView->SdrBeginTextEdit(mpSearchSpellTextObj, pPV, mpWindow, true, this,
pOutlinerView, true, true, bGrabFocus);
SetUpdateMode(true);
mbFoundObject = true;
} }
// To be consistent with the usual behaviour in the Office the text
// object that is put into edit mode would have also to be selected.
// Starting the text edit mode is not enough so we do it here by
// hand.
mpView->UnmarkAllObj(pPV);
mpView->MarkObj(mpSearchSpellTextObj, pPV);
mpSearchSpellTextObj->setActiveText(mnText);
// Turn on the edit mode for the text object.
mpView->SdrBeginTextEdit(mpSearchSpellTextObj, pPV, mpWindow, true, this,
pOutlinerView, true, true, bGrabFocus);
SetUpdateMode(true);
mbFoundObject = true;
} }
ESelection SdOutliner::GetSearchStartPosition() const ESelection SdOutliner::GetSearchStartPosition() const

View File

@@ -294,112 +294,112 @@ bool DrawView::SetAttributes(const SfxItemSet& rSet,
void DrawView::SetMasterAttributes( SdrObject* pObject, const SdPage& rPage, SfxItemSet rSet, SfxStyleSheetBasePool* pStShPool, bool& bOk, bool bMaster, bool bSlide ) void DrawView::SetMasterAttributes( SdrObject* pObject, const SdPage& rPage, SfxItemSet rSet, SfxStyleSheetBasePool* pStShPool, bool& bOk, bool bMaster, bool bSlide )
{ {
SdrInventor nInv = pObject->GetObjInventor(); SdrInventor nInv = pObject->GetObjInventor();
if (nInv == SdrInventor::Default) if (nInv != SdrInventor::Default)
{ return;
sal_uInt16 eObjKind = pObject->GetObjIdentifier();
PresObjKind ePresObjKind = rPage.GetPresObjKind(pObject); sal_uInt16 eObjKind = pObject->GetObjIdentifier();
if (bSlide && eObjKind == OBJ_TEXT) PresObjKind ePresObjKind = rPage.GetPresObjKind(pObject);
if (bSlide && eObjKind == OBJ_TEXT)
{
// Presentation object (except outline)
SfxStyleSheet* pSheet = rPage.GetTextStyleSheetForObject(pObject);
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Put(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
bOk = true;
}
if (!bSlide &&
(ePresObjKind == PresObjKind::Title ||
ePresObjKind == PresObjKind::Notes))
{
// Presentation object (except outline)
SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Put(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
bOk = true;
}
else if (eObjKind == OBJ_OUTLINETEXT)
{
if (bMaster)
{ {
// Presentation object (except outline) // Presentation object outline
SfxStyleSheet* pSheet = rPage.GetTextStyleSheetForObject(pObject); for (sal_uInt16 nLevel = 9; nLevel > 0; nLevel--)
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Put(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
bOk = true;
}
if (!bSlide &&
(ePresObjKind == PresObjKind::Title ||
ePresObjKind == PresObjKind::Notes))
{
// Presentation object (except outline)
SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
aTempSet.Put( rSet );
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Put(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
bOk = true;
}
else if (eObjKind == OBJ_OUTLINETEXT)
{
if (bMaster)
{ {
// Presentation object outline OUString aName = rPage.GetLayoutName() + " " +
for (sal_uInt16 nLevel = 9; nLevel > 0; nLevel--) OUString::number(nLevel);
SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pStShPool->
Find(aName, SfxStyleFamily::Page));
DBG_ASSERT(pSheet, "StyleSheet not found");
SfxItemSet aTempSet( pSheet->GetItemSet() );
if( nLevel > 1 )
{ {
OUString aName = rPage.GetLayoutName() + " " + // for all levels over 1, clear all items that will be
OUString::number(nLevel); // hard set to level 1
SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pStShPool-> SfxWhichIter aWhichIter(rSet);
Find(aName, SfxStyleFamily::Page)); sal_uInt16 nWhich(aWhichIter.FirstWhich());
DBG_ASSERT(pSheet, "StyleSheet not found"); while( nWhich )
SfxItemSet aTempSet( pSheet->GetItemSet() );
if( nLevel > 1 )
{ {
// for all levels over 1, clear all items that will be if( SfxItemState::SET == rSet.GetItemState( nWhich ) )
// hard set to level 1 aTempSet.ClearItem( nWhich );
SfxWhichIter aWhichIter(rSet); nWhich = aWhichIter.NextWhich();
sal_uInt16 nWhich(aWhichIter.FirstWhich());
while( nWhich )
{
if( SfxItemState::SET == rSet.GetItemState( nWhich ) )
aTempSet.ClearItem( nWhich );
nWhich = aWhichIter.NextWhich();
}
}
else
{
// put the items hard into level one
aTempSet.Put( rSet );
} }
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Set(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
} }
else
// remove all hard set items from shape that are now set in style
SfxWhichIter aWhichIter(rSet);
sal_uInt16 nWhich(aWhichIter.FirstWhich());
while( nWhich )
{ {
if( SfxItemState::SET == rSet.GetItemState( nWhich ) ) // put the items hard into level one
pObject->ClearMergedItem( nWhich ); aTempSet.Put( rSet );
nWhich = aWhichIter.NextWhich();
} }
aTempSet.ClearInvalidItems();
// Undo-Action
mpDocSh->GetUndoManager()->AddUndoAction(
std::make_unique<StyleSheetUndoAction>(&mrDoc, pSheet, &aTempSet));
pSheet->GetItemSet().Set(aTempSet,false);
pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
} }
else
pObject->SetMergedItemSet(rSet);
bOk = true; // remove all hard set items from shape that are now set in style
SfxWhichIter aWhichIter(rSet);
sal_uInt16 nWhich(aWhichIter.FirstWhich());
while( nWhich )
{
if( SfxItemState::SET == rSet.GetItemState( nWhich ) )
pObject->ClearMergedItem( nWhich );
nWhich = aWhichIter.NextWhich();
}
} }
} else
pObject->SetMergedItemSet(rSet);
bOk = true;
}
} }
/** /**

View File

@@ -75,30 +75,30 @@ namespace
OUString sColor; OUString sColor;
const SfxPoolItem* pColorStringItem = nullptr; const SfxPoolItem* pColorStringItem = nullptr;
if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem)) if (SfxItemState::SET != pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pColorStringItem))
return;
sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue();
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
else
aColor = Color(sColor.toInt32(16));
switch (nSlot)
{ {
sColor = static_cast<const SfxStringItem*>(pColorStringItem)->GetValue(); case SID_ATTR_CHAR_COLOR:
if (sColor == "transparent")
aColor = COL_TRANSPARENT;
else
aColor = Color(sColor.toInt32(16));
switch (nSlot)
{ {
case SID_ATTR_CHAR_COLOR: SvxColorItem aColorItem(aColor, EE_CHAR_COLOR);
{ pArgs->Put(aColorItem);
SvxColorItem aColorItem(aColor, EE_CHAR_COLOR); break;
pArgs->Put(aColorItem); }
break;
}
case SID_ATTR_CHAR_BACK_COLOR: case SID_ATTR_CHAR_BACK_COLOR:
{ {
SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR); SvxBackgroundColorItem pBackgroundItem(aColor, EE_CHAR_BKGCOLOR);
pArgs->Put(pBackgroundItem); pArgs->Put(pBackgroundItem);
break; break;
}
} }
} }
} }